Load testing is a crucial aspect of performance testing that evaluates how a system behaves under expected user load. Apache JMeter is one of the most popular open-source tools for performance testing. It allows developers and testers to simulate heavy user loads on applications, APIs, and websites to identify performance bottlenecks before they impact real users.
In this blog, we’ll take an in-depth look at load testing using Apache JMeter — examining its core features, how to execute tests, and best practices for effective implementation. We’ll also delve into a case study involving a high-severity customer issue that underscored the value of monitoring heap dumps and logs to assess CPU usage during high user load.
Introduction to Load Testing
Load testing is a type of performance testing that evaluates how an application performs under expected real-world usage. It measures response times, stability, and resource consumption when multiple users access the system simultaneously.
Why is Load Testing Important?
Imagine launching an e-commerce site, only to have it slow down or crash on Great Indian Sale Day. Load testing helps prevent such disasters by identifying performance bottlenecks before they impact users.
Why Use Apache JMeter for Load Testing?
Apache JMeter is one of the most popular tools for load testing due to its flexibility, cost-effectiveness, and ease of use. It allows you to simulate thousands of users accessing your application simultaneously, helping you identify performance bottlenecks.
Key Features of Apache JMeter for Load Testing
✅ Free and Open-Source — No licensing costs.
✅ User-Friendly GUI — Easy test creation without coding.
✅ Protocol Support — Works with HTTP, HTTPS, FTP, SOAP, REST, and more.
✅ Robust Reporting — Generates detailed performance analysis reports.
Installing Apache JMeter
System Requirements
- Java 8 or higher
- At least 4GB RAM (8GB recommended for high loads)
- Windows, macOS, or Linux
Step-by-Step Installation Guide
- Download JMeter from the official Apache JMeter website.
- Extract the ZIP file to a folder of your choice.
- Run JMeter by executing jmeter.bat (Windows) or jmeter.sh (Linux/macOS)
Understanding JMeter Components for Load Testing
Thread Group
Defines the number of virtual users (threads) and execution time.
Samplers
Sends requests to the system under test (e.g., HTTP, JDBC, FTP).
Listeners
Collects and displays test results.
Config Elements
Stores reusable settings like login credentials.
Timers
Adds wait times between requests to simulate real-world usage.
How to Create a Load Test in JMeter
- Open JMeter and create a new test plan.
- Add a Thread Group — Define user count, ramp-up period, and loop count.
- Add Samplers — Configure HTTP requests, API calls, or database queries.
- Add Listeners — Select result reports like Summary Report or Graph Results.
- Run the test and monitor system performance.
Running a Load Test with JMeter — API Load Testing
- Sends multiple API requests and measures response times.
- Ensures the API can handle concurrent requests.
Analysing Load Test Results
- Throughput — The number of requests processed per second.
- Response Time — The time taken for the system to respond.
- Error Rate — Identifies failed requests to pinpoint issues.
Best Practices for Load Testing with JMeter
✅ Define clear performance goals before running tests.
✅ Simulate real-world user behaviour using timers and think time.
✅ Run tests in non-GUI mode for better performance.
✅ Monitor CPU, memory, and network usage alongside JMeter results.
Case Study: Bank Website Crash Under High User Load
Customer Issue:
During peak user traffic, a bank experienced a major performance issue on one of its server instances, resulting in the crash of its public-facing website. The issue was traced back to excessive CPU and memory usage on the application server. Although the server’s maximum heap size was set to 5GB, inefficient garbage collection caused active user connections to pile up, ultimately exhausting system resources and destabilizing the server. The immediate solution involved restarting the production server to resume normal functionality.
Temporary Solution Implemented to Stabilize the System:
To rapidly stabilize the system, customized garbage collection settings were applied to the application, along with a recommendation to increase the JVM heap size from 5GB to 10GB
Actual Code Fix:
The issue with improper garbage collection was corrected in the code, and a permanent fix was implemented to resolve it.
Testing the Fix and Workaround:
The biggest challenge was validating the performance fix while ensuring that all product functionalities remained intact. To prove that CPU usage was reduced, two key tests were performed:
- Load Testing with Apache JMeter
- A load test plan was created and executed before and after applying the fix.
- Trace logs were analyzed to compare data usage and connection count.
2. Heap Dump Analysis from Application server
- Heap dumps were taken before and after the fix to assess memory usage.
Test Results:
- Before the fix: Logs showed 94–100 connections being created.
- After the fix: Connections dropped to 20–30, significantly reducing system load.
- Heap memory usage: A noticeable decrease was observed after applying the fix/workaround, confirming improved memory efficiency.
The implementation of both the temporary workaround and the permanent code fix stabilized the bank’s website, effectively preventing future crashes during periods of high user traffic.
Conclusion
Load testing with Apache JMeter is essential for ensuring application performance, scalability, and reliability under real-world traffic conditions. By following best practices, integrating with monitoring tools, and analysing results effectively, businesses can prevent performance failures and improve user experience.