Apache JMeter is a powerful open-source tool for performance testing. Here’s a detailed step by step guide to load test your web application running in Docker.
Before starting, ensure you have JMeter installed.
1.1 Install JMeter on Your Machine
Windows & Mac:
Download JMeter from the official site.
Extract the downloaded .zip file.
Navigate to the bin folder and run jmeter.bat (Windows) or jmeter (Mac/Linux).
Linux (via Terminal):
sudo apt update
sudo apt install jmeter -y
Docker Alternative (If you want to run JMeter inside a Docker container)
docker run -it --rm -v $(pwd):/tests -w /tests justb4/jmeter -n -t test_plan.jmx
docker-compose up -d
A test plan defines the load test scenario. Follow these steps:
3.1 Open JMeter
Run JMeter by executing:
jmeter
A GUI will open.
3.2 Add a Thread Group (Defines Users and Load)
Right click Test Plan → Add → Threads (Users) → Thread Group.
Configure:
Number of Threads (Users): e.g., 100 (simulates 100 users).
Ramp-up Period (seconds): e.g., 10 (users added over 10 sec).
Loop Count: Forever or 5 (how many times to repeat requests).
3.3 Add an HTTP Request Sampler
Right-click Thread Group → Add → Sampler → HTTP Request.
Configure:
Server Name or IP: localhost (or your Docker container’s IP).
Port: 8000 (or the port your app runs on).
HTTP Method: GET or POST (depending on API).
Path: /login or /api/data (endpoint you want to test).
If it's a POST request, add Body Data or Parameters.
3.4 Add Listeners (To View Test Results)
Right-click Thread Group → Add → Listener.
Select View Results Tree, Summary Report or Graph Results.
Once the test plan is ready, execute it.
Click the Run button in JMeter.
Monitor the results in the View Results Tree panel.
Analyze response times, error rates and throughput.
For better performance, run JMeter in command line mode:
Save the test plan as - test_plan.jmx.
Run JMeter using:
jmeter -n -t test_plan.jmx -l results.jtl
Ready to transform your business with our technology solutions? Contact Us today to Leverage Our DevOps Expertise.