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.

18 comments:

Anonymous 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 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

Anonymous said...

Fantastic - thanks again

PhiMic`s World said...

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

Chris said...

Nice introduction to a great tool!

Anonymous said...

thanks a lot, quick and simple!

V

Anonymous said...

Very easy to follow, thanks for these tips.

Khamosh Nigahein said...

Hi Zac,

I am in dire need of help and would be glad if u can help me.

I am new to JMeter. I am currently doing a performance testing of a web application using Jmeter. This web application uses Windows authentication.
When I am generating the request i am getting the following message in the response section of the "View Results Tree"

An NTLM Token was received.Your browser configuration is correct, but you have not logged into a supported Microsoft(R) Windows(R) Domain.Please login to the application using the normal login page.

I came to know that for windows authentication we need to use Http Authorization manager above the Http Request element.
This is the input i have given

Base url: http://localhost:3030
username: m1/userid
password:pass

I also tried changing
Base url: http://localhost:3030
username:userid
domain: m1
password:pass

I am still not able to resolve the issue. I would be great if someone could help me in resolving the above issue in JMeter. I also dont understand what is Realm, whether it is required or not and why

Thanks and Regards:
Azhar Rizvi, INDIA

Zac Spitzer said...

Hi Azhar,

Realm is the custom phrase you see in the browser username/password dialogue.

I haven't played with NTLM with JMeter, I try and avoid all that MS auth stuff where ever possible

Goodluck

Z

Unknown said...

Hi,

I'm also a new user of Jmeter. I have configured correctly and recorded some actions: Login to a web application (.NET) -> Create an event -> Create a message -> Log out -> Stop recording. While run the recorded script, it runs successfully, no error occurs but i found that data is not generated in database (MSSQL Server). But i can created data manually using the same entry screen of the application. I can't understand the problem. I have seen the result in several listner - View results in tree, View results in table, Summary report etc. Please let me know i have made any mistakes.

Regards,
Ashraf

Anonymous said...

Hi Zac!

Thank you so much for this article!
It's help me a lot!

Bring it on ;)

Have a nice day.

Domenico.

Anonymous said...

Great article and was very easy to understand too.

Anonymous said...

thanks was a great start to get going

Dzmitry said...

Thank you for good intro, Zac!
By the way, I know good library with JMeter How-to's and articles,
http://blazemeter.com/blog
http://community.blazemeter.com/knowledgebase/topics/10018-jmeter-tutorials

Unknown said...

Thanks, Quick Start up is really helpful.

Unknown said...

Thanks, its really a good help to start up

Muhammed Anees said...

Thank you! Very useful article

Muhammed Anees said...

Thank you for sharing, Very helpful article.