Load Testing With Apache JMeter

Apache JMeter Overview

Sam Kenny
Sam Kenny’s a(musing)
4 min readApr 21, 2013

--

JMeter is a simple yet powerful open source tool that provides the ability to perform load testing on an application. Although typically used for performing stress tests on web based applications, JMeter is also capable of distributing load on a variety of application protocols such as SOAP, Email, database calls via JDBC and many more.

Test plans in JMeter are built by using it’s gui to add predefined “out of the box” test elements. There are many different test elements in JMeter, but explaining most of them is out of scope for this post (phewww).

Examples of the most common test elements in JMeter include:

  • Thread Groups — Thread groups are the essence of any good stress test. Thread groups typically simulate users. For example, in my test plan I can define a thread group of 100 threads. The 100 threads is a way of simulating 100 users performing some actions.
  • Samplers — Samplers typically represent actions that can be taken by users. The most common used sampler in stress testing a web based application is an Http Request Sampler.
  • Listeners — What good is stress testing an application if we do not have a view of the results? That’s where samplers come in — Jmeter provides many pre-defined samplers that basically aggregate, graph and report on the results of any given test plan.
  • Proxy Configuration — JMeter can be used as a proxy server to record our activity against our web based application. Without this feature, it would be very difficult to setup a realistic test case to simulate some of the actions of our web based applications — this is primary due to the fact that web request encompass many different elements (cookies, session id’s, redirects etc). Instead of setting up these type of requests manually, we can configure JMeter as a proxy. Once configured as a proxy, we can browse our site normally and Jmeter will capture all the requests and use the captured requests as part of a test plan. For more information on using JMeter as a proxy server visit: http://jmeter.apache.org/usermanual/index.html.

To download the free version of Apache JMeter, please visit the following site:

Once installed, JMeter is nothing but an executable JAR file — hence the clunky java swing like interface.

Use Case — Middle Tier stress testing at C12 Capital.

Due to the design of the C12 middle tier mobile access entry layer, it is actually quite easy to perform stress tests using JMeter.

The blackberry communicates with the middle tier through HTTP requests passing name/value pairs. So the tests are simple and we only need a few test elements: Users, HTTP Requests and Listeners.

So first let’s setup our users

1). Open up JMeter, right click on the test plan icon on the left navigation bar and then click Add >> Threads >> Thread Group

2). Configure your thread group. For example, if we want to simulate 100 users our thread group should look like the following:

jmeter1

Note: The ramp up period basically tells JMeter to get X users running in Y seconds.

3). Add a HTTP request sampler.

Right click on the thread group and then click Add >> Sampler >> Http Request

The following screen displays what is required to setup a Blackberry PNL Summary Http Request

jmeter2

4). Now that we have simulate 100 users requesting PNL summary, it’s time to add a listener that will report on the results. To add a basic listener, right click on the thread group then click

Add >> Listener > Summary Report.

The following is an example of a summary report that was used on the stress tests I have been performing:

jmeter3

Once your test elements are configured, running a test is as simple as clicking run >> start in the menu bar.

--

--