Monthly Archives: October 2011

JMeter – Simulate multi-users scenario with counter

/** Vietnamese: bài viết trình bày về cách dùng JMeter Counter để  giả lập nhiều user truy xuất hệ thống cùng lúc **/

In load testing field, JMeter is a powerful tool, and powerful tool often means high learning curve. The fact that JMeter document is not so well-written caused programmers lots of troubles getting around with it. If you know how things to be done, it’s very simple. If not, you are going to spend several hours searching for the solution.

The situation: I need to simulate 1000 users to login in my system, using different username (ofcourse). After logging in, each user must input their activation code, gotten from the database. Then they go for the site functions as usual.

The interesting thing is that the activation code are random strings: I have no control how it be. But I must do mapping accurately from user to activation code. To do that, I write bootstrap code to generate  1000 users (user1 -> user1000) and their activation code. Next, export them to a CSV file to be read by JMeter.

  • user1,12345
  • user2,52341
  • user3,12534

But how to get those information to  JMeter? Using bean shell script, I managed to put these values in custom variables CurrentUser and CurrentUserActivationCode. But I must only put one pair of different value for each thread. Since JMeter have no global variable, I can’t tell it to increase each time a new thread start!

I searched for global variables for a while and try some suggestion (properties and the likes) without success. And then I remember that I only need a counter, because it simply doesn’t matter if the users log in in a order or not.

Solution: It’s JMeter Counter Config Element(actually I have no idea why a counter is a Config Element).

Sometimes it’s happy just because you have a work


Happy working

Don’t know why I spare the small time to write this post.

Sometimes happiness is hard to explain. Having a work, which you loved to do (or simply just because you do it well) is really a bless.

It’s kind of playing a game, but more… you have a product at the end. You know your hard work will yearn good results. You know that all your efforts are not for your own richness or pleasure. You know that what you create will last.

Hope you all find a good work. :)


Books – Cover, content and the presentation

/** Vietnamese: Cảm nghĩ khi xem bộ sách viết về kinh tế “Chào mừng 1000 năm thăng long – hà nội **/

Today I have a chance putting my hand on a series of Vietnamese economic books. That series is made to welcome the 10 centuries ceremony of Hanoi – Vietnam Capital.

I don’t have much time reading all the things. Skimming my way through the book, I feels that most of it are paragraphs with facts, bullets, numbers and so on… As far as I can tell, there’s no sharp argument or interesting question. If I am an economist, I may guess out the meaning of all those figures. But I’m not, so I’m lost.

The authors are all famous. They are professors, doctors… And to receive the task to write a book series for the most important ceremonies in this century… I don’t think they lack knowledge. But I must say that they failed to transfer their knowledge into their books.

When I first saw the books, I thinks positively: they are made to give us – normal citizens – the overview of the nation we live. But this series doesn’t seem to care about normal readers. Who will buy those books? Economists PhD & Master?

There’s a reason that Thaksin buy cell-phones for Thailand’s farmers. There’s a reason that Fukuzawa Yukichi writes lines that inspired a generation of Japan. Information are important. It’s important not only about what’s their content – how the information are organized & presented also matters much.

I still remember the feeling while reading Fukuzawa Yukichi, with all his enthusiam & efforts put in his works. The good books are the books which create the problem in readers’ head, and make them think. Only by thinking may the reader remember the content. Otherwise, it’s no difference to listening morning news.

Why is Facebook so fast?

It has been a time since my last post.

Truthfully, even now, I have been too busy to make a come-back. But I think a little writing will help this blog doesn’t seems as an abandoned castle.

Well, for sometime, I come across this question on StackOverflow:

Why Facebook performance is so good?

500 millions user, split for america, europe, asia. It means there’s more than a millionpeople viewing pictures, chatting with friends or update status at a time. How can they make it?

The main language of Facebook is PHP & MySQL, which doesn’t have reputation to scale well. AFAIK, people tends to use compiled language(like Java, .NET) for big enterprise application. Those languages enforces good practice like refactoring habit, good architecture,… while PHP does not. Moreover, scripting language can not run faster than compiled one, right?

There’s no single reason, but a whole lot of reasons:

  1. Heavy usage of caching (APC and memcached), which drastically cuts processing time. Slide 12 compares load time with APC (~130 ms) versus without it – 4050 ms. That’s 30x faster!
  2. Usage of HipHop, which converts PHP into C++ code (which is then compiled into much more efficient machine code than actual PHP).
  3. Facebook uses PHP and MySQL, but that’s not the only thing they use. For example, they useErlang for their chat, Hadoop clusters for some of their storage. If you go visit their careers page, you’ll see they are hiring developers with experience in C++, Java, Python, and others.
  4. Facebook has data distributed across many, many servers. In June 2010, FB had 60,000 servers. (think that’s too much? Google had half a million… 5 years ago)
  5. Facebook sends as little traffic as possible: they use static CDNs to deliver static content. Gzip to compress data. Cookies, Javascript, HTML – everything is cut back to reduce the number of bytes sent over the network. They use a technology they call “BigPipe”, which sends partial content rather than the whole page.

to mention a few…