Main Content

Jmeter - a first test case

Archive - Originally posted on "The Horse's Mouth" - 2009-03-14 17:54:41 - Graham Ellis

Would you like to see how your web site performs under load? I mentioned ApacheBench (ab) in a recent post, but you can also use a tool like Jmeter. And although Jmeter is written in and runs in Java, you can use it to look at the performance of other servers and network resources too.

In famous "Blue Peter" jargon, 'here is one I put in the oven earlier' ...

... and the reason I put one in the oven earlier is because like all things Java, the documentation and setup looks very complicated at first.

How did I set this up?

0. I fired up Jmeter - previously downloaded and unpacked - making sure that a Sun JRE was 'top dog' in my PATH.

1. I started a new TEST PLAN

2. I added a THREAD GROUP
(4 users, 4 seconds ramp up, 200 loops)

3. I added an HTTP REQUESTS DEFAULT within Config Element
(wellho.net as the server but please use your own if you're following this!)

4. I added an HTTP REQUEST within Samplers
(path to /robots.txt)

5. I added a GRAPH RESULTS under listener

6. I saved the configuration as a .jmx file (robots.jmx)

and I chose "run" ...

Let me fill you in on those results. There were 800 samples taken as I asked for 200 sets of 4 samples, and I spread the sample sets out over 4 seconds apiece, so the total run time was about 3 minutes.

The sprinkling of black dots represent the individual samples and how long each of them took, with the blue line showing the average time and the purple line showing the median (time of the 50 percentile sample, which is a little bit different). The red and green lines are on different scales - the red line showing the deviation or variance which was high at first (probably because the first few samples would have been slow, the later samples consistently faster) and the green lines shows the throughput achieved - that starts low and rises, again because of early slow samples.

Right. Here is a stern lesson. Do NOT run Jmeter against a server that you don't own / don't have permission to try it out on. Tests like the one I have done above are cruel and can bring a server to its knees very quickly, so using Jmeter is a way to make yourself very unpopular! BUT if you're configuring a new environment it's a great tool!


I have only started to scratch the surface here ... as you put your first test plan together, follow what I have done on your own server .... and as you put your second plan together, have a look at the manual that covers it from Apache - in particular chapter 5 - here. You'll find it's very clever in terms of logging in, posted data, handling cookies and doing a lot more to simulate real traffic. Proceed further and you'll find that you can combine thread groups that are being run by different instances of Jmeter into a single report, and get some very sophisticated load testing running.