How to use Apache JMeter to perform Load Testing

2 August, 2021 Technology

 

Various software testing techniques can be carried out using tools like Apache JMeter, to optimize testing efforts in a development environment. Whether it is functional and non-functional testing, each approach comes with its own benefits and limitations.

 

Examples of functional testing include system and interface testing whereas non-functional refers to performance, stress, and load testing. This basic tutorial outlines how to use the JMeter testing tool to improve the load testing process.

 

Why Apache JMeter?

Using JMeter in software testing services has a different purpose to using tools like Selenium. Although both are open-source and developed by Java for web application testing, their implementation is not the same.

 

JMeter testing analyzes program and server performance while handling heavy processing loads. It tests the performance of static resources (e.g. HTML) and dynamic resources (e.g. Servlets) and then provides graphical performance reporting and test results.

 

Strategize Load Testing

Load testing determines how a program performs under simulated real-life multi-user activity and load conditions. It is different from stress testing, which identifies the program or system's breaking point. With load testing, you can find and address bottlenecks before releasing them to production.

 

The primary measurable for load testing is the response time of the program under a heavy load, so you should determine what's acceptable and what is achievable before testing starts.

 

Develop an Approach

Work with your DevOps team to set out a testing plan that clarifies the approach, requirements, and goals.

  1. Setup a dedicated test environment.
  2. Define the load testing scenarios, prepare the data and transactions.
  3. Specify the predicted number of users who will access the program and consider varying connection speeds, browsers, and operating systems.

Key Advantages

It's been known to happen where websites crash due to excessive site traffic and processing loads. Planning for these scenarios through load testing is key to product stability as it identifies the following:

  • System's operating capacity during high traffic and transaction loads.
  • Suitability, sustainability, and scalability of the system.
  • Performance of all components under heavy loads.
  • Configuration and design issues, and limitations of the software and hardware.

How to use Apache JMeter for Load Testing

The following overview explains how to get started with a basic load test using Apache JMeter.

 

Installation

To use the JMeter testing tool, first, install the Apache JMeter client application on a computer with an operating system compatible with Java 6 or later. Make sure the testing environment is separated from the production servers.

 

Build a Test Plan

Open the JMeter testing tool to create your first new test plan. The test plan is a sequence of components that simulate the test load.

 

Add Thread Groups

Next, add a Thread Group, which is an important group of properties that will impact the testing.

 

Right-click on the new test plan and select Add > Threads > Thread Group to define the attributes:

  • Number of Threads (users): Specify how many users will be simulated for the test. Recommended value 50.
  • Ramp-Up Period (in seconds): Indicate the time over which JMeter distributes the threads. Recommended value 10.
  • Loop Count: Denote how many times to execute the test. Recommended value 10.

Define HTTP Elements

Add the following HTTP components to the test plan:

  • HTTP Request Defaults: Set default values especially when sending multiple HTTP requests to the same target. Set the default web server details (server name or IP) for all the HTTP elements to indicate where the program resides that needs to be tested.
  • HTTP Request Sampler: Specify the path that represents the page request each user (thread) will access. Using a backlash /instead of a full path name indicates the homepage of the server.

Configure the Listeners

JMeter uses "listeners" to provide the test results output. Several listeners can be used, and, in this tutorial, the test results are added to the Table listener.

 

Run the Load Testing Plan

To run the basic test plan and view test results, save the test plan.

  1. In the left pane, click on the option, View Results in Table, and then select Run from the main menu.
  2. Click on Start (or use the green Start button).
  3. Once the test results are generated, it will be displayed in Table format.

Test Results View

The status of every request is shown along with various statistics on the load test. Key values to analyze are:

  • Latency: Time in milliseconds from when JMeter sends the request to when the first response is received.
  • Sample Time: Time in milliseconds for the server to manage the request.

Conclusion

Apache JMeter is an invaluable tool for assessing and refining a web application environment. To get the most from your testing efforts, load testing should only be run on functionally stable programs.

 

After this basic introduction to JMeter, get started with installing the testing tool and experimenting with different scenarios so you can fine-tune your test plans.

 

Author's bio:

Kate Zalozna. CTO at QA Madness. I'll share my knowledge and experience of implementing QA strategies and ensuring their alignment with a company's business needs. After working in QA and software testing for over 9 years, I have a lot of things to share.

Description

youmobileorg
Posts: 8431





© 2023 YouMobile Inc. All rights reserved