I previously used ab
(ApacheBench), the built-in stress testing tool from Apache, but found it less convenient. After some research, I discovered a tool called JMeter
.
Installing JDK
Since JMeter is developed in Java, we need a Java Runtime Environment (JRE). For simplicity, we’ll install the full JDK (Java Development Kit):
- Visit the official Oracle download page:
https://www.oracle.com/technetwork/java/javase/downloads/index.html - Select JDK download:
JDK Download - Accept the license agreement and download the appropriate version for your OS (Windows in this case):
JDK Version - Run the installer with default settings (note the installation directory):
JDK Installation
Configuring Environment Variables
- Locate the JDK’s
bin
directory (e.g.,C:\Program Files\Java\jdk-11.0.1\bin
) and copy the path.
JDK Bin Path - Add to System Path:
- Paste the JDK
bin
path into the Path variable:
Path Configuration - Verify by running
java --version
in Command Prompt:
Java Version Check
Installing JMeter
- Download JMeter from the official site:
http://jmeter.apache.org/download_jmeter.cgi
JMeter Download - Extract the ZIP file to your preferred directory (JMeter is portable).
- Launch JMeter by running
bin/jmeter.bat
:
JMeter Launch - Set Chinese localization (optional) by editing
jmeter.properties
:language=zh_CN
Usage Guide
- Create a new test plan: File → New
New Test Plan - Add a Thread Group:
- Configure Thread Group:
- Add an HTTP Request:
- Configure HTTP Request:
- Add listeners for results:
- Run the test (Run → Start) and save the test plan when prompted:
Run Test - View results in listeners:
Test Results
Aggregate Report
Aggregate Report Metrics Explained
Metric | Description |
---|---|
Label | Name of the request (e.g., HTTP Request) |
# Samples | Total requests sent to the server |
Average | Average response time per request |
Median | 50th percentile response time |
90% Line | 90th percentile response time |
95% Line | 95th percentile response time |
99% Line | 99th percentile response time |
Min | Minimum response time |
Max | Maximum response time |
Error % | Error rate = (Failed requests / Total requests) × 100 |
Throughput | Requests per second (RPS) |
Received KB/sec | Data received per second from the server |
Sent KB/sec | Data sent per second from the client |