JMeter tutorial – How to Perform Load Testing Using JMeter

JMeter is a basic open source tool for carrying out load and ramp-up testing. It lets you conduct fairly simple testing with uncomplicated scenarios.

What Is JMeter?

JMeter is a test tool from Apache used to analyze and measure the performance of applications, different software services and products. It is open source software entirely written in Java, used to test both web and FTP applications as long as the system supports a Java Virtual Machine (JVM).

It is used to conduct performance, load and functional testing of web applications with low levels of complexity. Apache JMeter can also simulate a heavy load on a server by creating multiple simultaneous virtual users on a web server.

Try NeoLoad, the most automated performance testing platform for enterprise organizations continuously testing from APIs to applications.

 

Steps to Perform Load Testing with JMeter

1 – Build a basic test plan

When JMeter starts, you should see the graphical user interface with an empty test plan. To create a load test, start by configuring the different components that will determine how it will be simulated. 

1-1 Add a Thread Group

To start, add a group of threads to the test plan:

  1. Right-click on Test Plan.
  2. Hover mouse over Add>.
  3. Hover mouse over the Thread (Users)>.
  4. Click Thread Group.

The Thread Group influences the load test by controlling three properties you will need to configure:

  • Number of threads, i.e., users, that JMeter will try to simulate
  • Ramp-up period in seconds (this is the time left between each new user generated by JMeter)
  • Number of loops, i.e., the number of times the test will be run

1-2 Add a default HTTP request

This configuration element is used to set the default values for HTTP requests in the test plan. This is particularly useful for sending multiple HTTP requests to the same server during testing. To add a default HTTP request you need to:

  1. Select the Thread Group, then right-click.
  2. Hover mouse over Add>.
  3. Hover mouse over Config Element>.
  4. Click on HTTP Request Defaults.
  5. Fill in the Server Name or IP field with the name or IP address of the webserver you want to use as the default server.

Automate API and end-to-end application performance testing with NeoLoad, the continuous performance testing platform.

 

1-3 Add an HTTP cookie manager

If your web server uses cookies, you can add an HTTP cookie manager to the thread group. To do this, you need to:

  1. Select the Thread Group, then right-click.
  2. Hover mouse over Add>.
  3. Hover mouse over Config Element>.
  4. Click on HTTP Cookie Manager.

1-4 Add an HTTP request sampler

An HTTP request sampler represents a page request that each thread (user) will access during the test. It’s possible to add different requests, in which case each thread will execute all requests.

To generate an HTTP request sampler, you need to:

  1. Select the Thread Group, then right-click.
  2. Hover mouse over Add>.
  3. Hover mouse over Sampler>.
  4. Click on HTTP Request.
  5. In HTTP Request, fill in the path with the item that you want each thread (user) to request.

Note: It’s not necessary to specify the server in this element, as this has already been done when configuring the default HTTP request.

JMeter can display test results as a graph for easier reading. To do this, simply:

  1. Hover mouse over Test Plan, then right-click.
  2. Hover mouse over Add>.
  3. Hover mouse over Listener>.

Click on Graph Results.

2 – Run the test and analyze the results

2-1 Run the test

Once the test plan is established, you’ll need to run it to get some results. To do this, follow these steps:

  1. Save the test plan by clicking on File and then Save.
  2. Enter the file name.
  3. Select View Results in Table in the left pane.
  4. Click on Run in the main menu.
  5. Click on Start or on the green start arrow under the main menu.

When the test has been run, results are displayed in the table with the following color coding:

  • Black indicates the number of current samples sent.
  • Blue indicates the current average of all samples sent.
  • Red indicates the current standard deviation.
  • Green indicates throughput rate, which represents the number of requests per minute that the server has processed.

2-2 Interpret the results

You’ll probably see the status of all requests showing as “Success,” indicated by a triangle with a green tick. The results of notable interest will be:

  • Latency: number of milliseconds that elapsed between the time JMeter sent the request and the time an initial response was received
  • Sample time: the number of milliseconds the server took to fully satisfy the request (response + latency).

These results must then be compared with the expectations and objectives defined before testing to determine whether the application is working reasonably well or not.

Start testing with NeoLoad, the fastest, the most realistic, and the most automated continuous performance testing platform.

 

3 – Increase the load

After having first carried out a successful test with a defined load, it’s possible to increase the load to run a second test to see how many threads your web application server can handle before it begins to exhibit performance degradation. 

To increase the load, you must:

  1. Change the number of threads in the left pane of the Thread Group.
  2. Click on View Results in Table, then on Start to start a new test.

Then you’ll need to analyze the results of these tests to determine any and all weak points in the application. This type of testing helps make sure the application can handle higher loads than is normally expected – avoiding problems under heavy loads, whether temporary or over time. It also helps you anticipate the evolution of the application so it’s less likely you’ll encounter a bug when demand increases.

As a basic open-source tool, JMeter lets you conduct fairly simple testing with uncomplicated scenarios. If you want to generate more complex scenarios, however, and test applications with an increased number of parameters to configure, you’ll need a more sophisticated software testing tool like NeoLoad to be effective.

Test API and application with NeoLoad, the most automated continuous performance testing platform.