RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Load Testing with Apache JMeter

Got a handle on how much your Website can handle? Use Apache's new Jmeter to perform fast, easy load testing on your Web pages, Web applications, and databases.


bad response time on your Web site can drive away visitors and prospective customers. Unfortunately, you may not realize that your Web site is having problems until people start complaining. To gain a more quantitative insight as to what your site can handle, you need a way to simulate and analyze different load scenarios.

Using Jmeter, a powerful performance tool from the Apache Jakarta project, you can load test Web pages, Web applications, databases, and several other static and dynamic resources.

Install Jmeter
First off, download Jmeter. We are using the version 1.9.1 of JMeter on a Microsoft® Windows® XP Professional platform. Unzip the downloaded file into a directory. We'll refer to this directory as [JMeter-Root].

In order to run JMeter, you need to run one of the following:

  • [JMeter-Root]/bin/jmeter.bat (in Windows)
  • [JMeter-Root]/bin/jmeter (in Unix)

After the main screen loads, you'll notice two elements in the left pane, Test Plan and Workbench. The Test Plan is a container for running tests. The Workbench is a sandbox for any test or portion of a test that you are working on. When you are ready to test what you have designed in the Workbench, you can copy or move the elements into the Test Plan.

Figure 1. Right clicking on the Test Plan reveals the context menu.

The Test Plan
Right-click on the Test Plan icon to see the context menu (shown in Figure 1) that allows you to add sub elements.

You can use the Add feature to create a hierarchy of elements that will then execute when you run your test. The level in which an element exists determines the elements upon which it has an effect. Generally, higher elements within a branch of the hierarchy will affect lower elements within the hierarchy. For example, if you put a timer at the root level of the Test Plan, it will apply to all tests that exist under the Test Plan.

Here's a summary of the elements to be demonstrated in this article:

Thread Groups
A thread group allows you to define the behavior of a group of threads that will interact with your application. Think of each thread as a person sitting at their computer, trying to access a given Web page. You will use thread groups to define the number of threads that a test will launch.

Timers are used to create delays between requests made by each simulated user. Without a timer, your requests hit the server back to back, as fast as possible. Timers allow for a more realistic load on the server. There are different types of timers that allow you to produce either constant or random delays.

Listeners gather data as your tests run, and allow you to report on that data. You can use listeners to create graphs or export data to files.

Target Web Page
This article's example is deliberately simple. There are two static Web pages: one with an 800x600 pixel image that is approximately 50K in size and another with a 1024x768 pixel image that is approximately 250K in size. Download them here.

Here, two separate tests are conducted to demonstrate the difference in server-side response time. Jmeter can show exactly how the server's response time differs for a file that is five times larger than another, under the same exact load. This type of test is particularly helpful when deciding whether or not to optimize your Web site images.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date