Wednesday, March 05, 2008

A quick howto to setup JMeter

JMeter is an open source load testing tool, it's pretty easy to get up
and running and it's quite fun to test and break things on your own server.

Here's a quick getting started guide on how to record a simple test plan.

Download and install JMeter

Open Jmeter (bin/Jmeter.bat on Windows)

Add (via right click) a Thread group to the Test Plan

Add a Non Test Element > HTTP Proxy Server to the Workbench

Open the HTTP Proxy Server Page and change the port if required

Set the Target Controller to Test Plan > Thread Group on the same page



Configure your browser (Firefox!) to use the Proxy Server (it's localhost)

Press Start at the bottom of the page

Now, JMeter will record all the HTTP requests your browser makes, so make sure you have closed all the other tabs you have open, otherwise you will get a mixture of Ad's and ajax requests recorded as well.

As an example, tonight I was doing some load testing on the Tile service for Mapguide, so I opened a map and zoomed in and panned around a bit. Then I pressed Stop in JMeter and I had a list of HTTP requests. Simple!

Don't forget to reset your browser proxy settings!



You can delete any requests you don't want from the list at any time.

Add a Timer > Gaussian Random Timer to the Thread Group which will make the requests random.

Add a Listener > Aggregate Report to the Test Plan

Now for the first run, the default load setting is fine.

Select the Aggregate Report and the from the top menu click Run > Start



If that worked out ok and there are no errors, you can the configure the thread group to run multiple times with multiple users. You can see I had an error rate of 100% in the example above.



If you get errors, check your webserver and application server logs. You can also log and view each http request and response using Listener > View Results in Table. Filtering to only show errors is also helpful.




If you are running a big load test, remember each Listener keeps a copy of the results in memory so you might be better running a Listener > Simple Data Writer instead which writes the results out to a file. You can then read the file in later into any of the reports.

Overall it took me a bit of time to get familiar with JMeter, there's lots of cool things you can do with it. Keep in mind session handling (cookies) for dynamic applications as well!

Remember to read the documentation and be careful! Make sure you know what servers will be affected by your testing, and don't jump to simple conclusions, 3-tier web apps are complex beasts.

I have seen developers trying to solve a performance issue and completely misunderstanding the problem. Then they go and try and solve the wrong problem, usually involving lots of wasted coding.

Always start with a smaller load, you better off finding and fixing a bug which occurs often under low load, than an obscure bug which occurs only under extreme load.

4 comments:

Antony said...

This could be the intro to load testing I've been waiting for. Thanks heaps! Any quick tips on how to simulate authenticated users?

Zac Spitzer / Fastmovingtarget said...

This component handles it - HTTP_Authorization_Manager
you can even feed it a CSV of users to select from

I'm glad you found my intro useful

Antony said...

Fantastic - thanks again

PhiMic`s World said...

Very nice posts, this was what i am looking for :)

Related Posts Widget for Blogs by LinkWithin