How to Choose the Number of Threads for an Apache JMeter Test Plan

Apache JMeter is a flexible open-source tool for performance and load testing of web applications. At Logicify, QA specialists widely use it too. We listed JMeter advantages and main terms in one of our previous articles. To make the testing process even more effective, it is obligatory to properly choose the number of virtual users (threads) to execute the given test plans and create a needed server load.

The number of virtual users executing the test would depend on multiple factors, such as your goal while testing, parameters of your local PC and the network, and script complexity. Before you decide on the optimal number of virtual users for your JMeter test plan, consider the following tips.

1. Examine Server Logs

Server logs contain the history of web-requests with users’ IP-addresses, date and time. So, a graph showing the server load over a week would give you an idea about the average number of real users and their requests (hits) for low, normal, and high server loads. Target the peak number of requests as opposed to average one to be replicated in your JMeter test plan.

Though JMeter does not offer a native listener to identify the number of active virtual users for a thread group in every given point of time, in Logicify we use a third-party plug-in called Active Threads Over Time. It presents this number on simple yet laconic graphs.

Approaches to Server Loading

While load testing, you could build up various loads on the server by adjusting JMeter Thread group properties.

  • Linear load — one of typical server loads while performance testing.

Linear load is good for majority of cases, yet test results would not be indicative if the server crashes during the load rise. In this case, it makes sense to examine the point where the system failed and start from there to determine its maximum load.

  • Step load — allows to let virtual users out in chunks, for example, 25, then 25 more, and 25 more. This approach is more reliable and indicative of system performance under different loads, with varied number of virtual users executing the test in every given time interval.

Native JMeter functionality does not support such a complex load scenario, so at Logicify we use a third-party plug-in called Ultimate Thread Group to set Thread group parameters and examine the system behavior after every new chunk of virtual users is added. This plug-in is also good for stress testing and determining the so-called “system saturation point” — a load point where further increase in the number of users leads to longer response time or system instability.

  • Peak load — short-time extremely intensive load on the server. It allows to examine the reaction of the system on such extreme load jumps and the way it recovers back to its initial performance indicator after the peak load is over.

2. Investigate Google Analytics for a Website

If the website under testing is available publicly, Google Analytics reports on Audience and Behavior would also be helpful in determining the optimal number of virtual users in Thread groups. When testing a company website, the total count of requests (hits) could be predicted based on the number of employees, their working hours and schedule, plus a certain number of request added on top of these — as a reserve.

3. Check System Requirements

Technical requirements for a system performance should be documented in the specification or performance test plan and discussed with the client in advance. They aid in finding the optimal number of virtual users for testing.

If you connect the server with the web page and JMeter client via local network, with a more stable connection as compared to the Internet — this could be figuratively called “lab” testing — you minimize the number of factors affecting response time and focus more on the system itself to find potential bottlenecks. On the other hand, connecting to the server via the Internet is a more true-to-life scenario. Yet, it makes root cause analysis and issues isolation harder.

4. Anticipate Traffic Splashes

Find out if the website may see a rapid splash in visitors while you plan performance testing. For instance, when testing an e-commerce application, be ready for seasonal sales or Black Fridays, which attract more visitors. You should be sure that the website is ready for such hit-and-run raids and execute load testing with a large number of virtual users in advance.

Choosing the optimal number of virtual users in JMeter makes testing results true-to-life and more indicative.

We have JMeter few tips and lifehacks proven by own experience, for instance, how to make a JMeter test plan even more effective. Check these out!


Originally published at www.logicify.com/en/blog on November 7, 2018.