JMeter Crash Course

May 07, 2012

I have had a lot of success using JMeter to provide quick performance tests, and this guide will help you get started with JMeter.  I have used JMeter with success on web applications, web services and databases, and I find that it works extremely well.  I have even used JMeter on .NET projects.  This doesn't cover performance testing best practices.  I will save those for another post.

Download and install the Java SDK

  1. Download the SDK from Oracle here (Note: Recommend Java SE 6 update 27.  I've had issues with update 29)
  2. Run the installer.  Take note of the install location
  3. Add $java_install_dir/bin/ to your system path

Install JMeter

  1. Download JMeter from Apache's website:
  2. Unzip to a location on your machine.
  3. Add $jmeter_install_dir/bin to your path (Note: if you are using Windows, then I recommend just creating a shortcut to $jmeter_install_dir/bin/jmeter.bat)
  4. Run the bin/jmeter command and you should see JMeter open a window.

Recording a Script

The following instructions will setup JMeter to record a performance script that you can use for replay.  This is the fastest way of setting up a performance test script.

  1. Right-click on Test Plan and then select Add > Threads (Users) >  and Create a ThreadGroup
  2. Right-click on the Workbench then select Add > Non-Test Elements > HTTP Proxy Server
    1. Set the Target Controller to "Test Plan >  Thread Group"
    2. Set the Grouping to "Store 1st sampler of each group only"
    3. Add Exclusions
    4. Change Port (Optional)
    5. Start the Proxy Server
  3. Click the Start button on the Http Proxy Server
  4. Update IE to use a Proxy Server
    1. Internet Options
    2. Connections Tab
    3. LAN Settings
    4. Click 'User Proxy Server'
    5. Enter localhost and port.
    6. Click OK and OK.
  5. Start clicking through your application (make sure JMeter is recording your clicks)
  6. Save the recording.

Adding Listeners

JMeter uses listeners to record the results of the performance test.  Take a look at the various types of listeners here and add one by right clicking on the Thread Group and adding a Listener there.

Running a Performance Test

Once your script is recorded and you have added listeners, make sure you save your script.  Now you can run it!

  1. Open up the ThreadGroup node and make the following changes:
    1. Change the Number of Threads to the number of concurrent users you would like to run in the performance test.
    2. Change the Ramp-up Period to the number of seconds it takes for all the users to start.
  2. In the menu, click Run, Start.
  3. Sit back and watch JMeter ramp up!

Final Thoughts

This post is intended to get you started with a simple JMeter performance test.  I also only focused on using JMeter to performance test a web application.  JMeter can performance test web apps, databases, JMS servers, email servers, LDAP servers, web services, and much more.  I recommend taking a look at JMeter's manual, available here.

Share this:

comments powered by Disqus