⚙️ Basic of JMeter
Created By: Shadikun Nahar Sakiba
1. What is JMeter?
● Apache JMeter is an open-source tool used for performance testing and
load testing of web applications, APIs, databases, and other services.
● It simulates multiple virtual users sending requests to your server to
measure performance, throughput, and reliability.
● Can test:
○ Web applications (HTTP/HTTPS)
○ SOAP/REST APIs
○ Databases (via JDBC)
○ FTP, JMS, Mail, LDAP
○ TCP services
2. Key JMeter Components
a. Test Plan
● The main container in JMeter.
● Holds all threads, samplers, listeners, and configurations.
● You can parameterize and control execution flow here.
b. Thread Group
● Represents a group of virtual users.
● Each thread is one virtual user.
● Key parameters:
1. Number of Threads (Users): Number of virtual users to simulate.
2. Ramp-Up Period (seconds): Time to start all users gradually.
■ Formula: Ramp-Up / Threads = Time between
starting each user
■ Example: 10 users, 20 sec ramp-up → 1 user starts every 2
seconds.
3. Loop Count: Number of times each thread executes the test.
4. Scheduler: Can schedule test duration.
c. Sampler
● Defines what action the thread will perform.
● Examples:
○ HTTP Request → Calls a URL.
○ JDBC Request → Executes a SQL query.
○ FTP Request → Upload/download files.
d. Listener
● Used to view and analyze test results.
● Examples:
○ View Results Tree: Shows request/response data.
○ Summary Report: Shows aggregated stats.
○ Graph Results / Response Time Graph: Visualizes trends.
e. Config Elements
● Provide data or configurations to samplers.
● Examples:
○ HTTP Request Defaults: Set default server/path.
○ CSV Data Set Config: Parameterize requests with external data
(usernames, IDs).
f. Timer
● Introduces delay between requests.
● Helps simulate real-world user behavior.
g. Assertion
● Used to validate responses.
● Examples:
○ Response contains a string.
○ Response code is 200.
h. PreProcessor / PostProcessor
● PreProcessor: Runs before request (e.g., add headers, encode data).
A Pre-Processor in JMeter is a component that runs before an HTTP
Request (or sampler) is sent.
Its purpose is to manipulate data, variables, headers, or the request itself
dynamically for each iteration or thread.
✅ Key Use Cases:
● Add dynamic values (random numbers, timestamps) to requests.
● Modify headers or body before sending.
● Prepare variables for the upcoming request.
● PostProcessor: Runs after request (e.g., extract token using regex).
A Post-Processor is a JMeter component that runs after an HTTP request
(sampler) is executed.
Its main purpose is to extract or process data from the server’s response
so it can be used in subsequent requests.
✅ Key Use Cases:
● Extract IDs, tokens, session values from responses.
● Validate dynamic response content.
● Feed data into the next HTTP requests in the workflow.
3. Important JMeter Terms
a. Thread
● A virtual user in JMeter.
● Executes samplers independently.
● Multiple threads = concurrent users.
b. Throughput
● Number of requests processed per unit time.
● Unit: requests/sec or requests/minute.
● High throughput = server can handle many users efficiently.
c. Ramp-Up
● Time to start all threads.
● Helps avoid sudden load spike.
● Formula example:
Ramp-Up = 10 sec, Threads = 5 → 1 thread starts every
2 sec
d. Response Time
● Time taken by server to respond to a request.
● Lower is better.
● Types:
○ Average Response Time
○ Median Response Time
○ 90th Percentile (time within which 90% of requests complete)
e. Sample Time
● Time taken to complete one sampler request.
● Measured for each thread separately.
f. Latency
● Time from request sent to first byte received.
● Useful to check server/network delays.
**g. Error %
● Percentage of requests that failed or returned errors.
● Formula:
Error % = (Number of failed requests / Total requests)
* 100
h. Threshold
● Performance limit set for response times, errors, or throughput.
● Example: “All requests must respond within 2 sec” → Threshold = 2 sec.
i. Load / Stress Testing
● Load Testing: Test application at expected user load.
● Stress Testing: Test application beyond max capacity to see failure points.
4. Metrics JMeter Shows
Metric Meaning
Throughput Requests/sec handled by
server
Response Time server takes to respond
Time
Latency Time to first byte
Sample Number of requests sent
Count
Error Count / Number/percentage of failed
% requests
KB/sec Bandwidth used during test
5. JMeter Execution Modes
1. GUI Mode: For designing and debugging test plans.
Non-GUI Mode: For actual load testing and report generation.
jmeter -n -t [Link] -l [Link] -e -o
report-folder
6. JMeter Functions
● ${__Random(1,100)} → Generate random number.
● ${__time()} → Current timestamp.
● ${__UUID()} → Generate unique ID.
● ${__CSVRead([Link],0)} → Read data from CSV file.
● ${__BeanShell()} or ${__groovy()} → Custom scripts.
Functions allow dynamic data and parameterization.
Ramp Up Time calculation:
🎯 Example Setup
Setting Value
Number of Threads (users) 10
Ramp-Up Period (seconds) 20
🧮 What JMeter Does Internally
JMeter must start 10 users within 20 seconds.
That means:
Ramp-Up Time per User=Ramp-Up PeriodNumber of Users=2010=2 seconds\text{Ramp-Up
Time per User} = \frac{\text{Ramp-Up Period}}{\text{Number of Users}} = \frac{20}{10} = 2 \text{
seconds}Ramp-Up Time per User=Number of UsersRamp-Up Period=1020=2 seconds
✅ So, every 2 seconds, JMeter will start one new virtual user.
🕒 Timeline Example
Time Action
(sec)
0 User 1 starts
2 User 2 starts
4 User 3 starts
6 User 4 starts
8 User 5 starts
10 User 6 starts
12 User 7 starts
14 User 8 starts
16 User 9 starts
18 User 10 starts
20 All 10 users are now running concurrently
📘 What This Is Called
This calculation or concept is known as the “Ramp-Up Rate” or “User Start Interval.”
Formula:
Ramp-Up Rate=Ramp-Up PeriodNumber of Threads\text{Ramp-Up Rate} = \frac{\text{Ramp-Up
Period}}{\text{Number of Threads}}Ramp-Up Rate=Number of ThreadsRamp-Up Period
It tells you how often (in seconds) JMeter will launch a new user.
🧩 Your Setup
Setting Value
Threads (Users) 10
Ramp-Up Period 20
seconds
Loop Count 2
🔹 1️⃣ Meaning of “Ramp-Up Period = 20 seconds”
This doesn’t mean the whole test will finish in 20 seconds.
It means:
“It will take 20 seconds just to start all 10 users.”
So, by 20 seconds, all 10 virtual users are active (started),
but they are still running their tests (executing HTTP requests).
🔹 2️⃣ How Ramp-Up Works in Time
Each user starts 2 seconds apart:
20 sec ramp-up÷10 users=2 sec per user20\text{ sec ramp-up} ÷ 10\text{ users} = 2\text{ sec
per user}20 sec ramp-up÷10 users=2 sec per user
Time User Action
(sec)
0 User 1 starts
2 User 2 starts
4 User 3 starts
... ... ...
18 User 10 starts
20 ✅ All users are now active
🔹 3️⃣ What Happens After Ramp-Up
Now all 10 users are running their loops.
Each user:
● runs Loop 1
● then immediately runs Loop 2
● independently, based on when they started
So the total test time depends on:
1. How long your requests take (the duration of each loop)
2. Ramp-up time
🧮 Let’s Take an Example
Let’s assume:
● Each loop (one full test) = 10 seconds
Then:
User Start Time Loop 1 Loop 2 Ends At
(10s) (10s)
User 1 0s 0–10s 10–20s 20s
User 2 2s 2–12s 12–22s 22s
User 3 4s 4–14s 14–24s 24s
… … … … …
User 18s 18–28s 28–38s 38s
10
🧠 So, What’s Actually Happening?
● Ramp-Up = just the time to start all users (not total test time)
● Loop 2 starts after Loop 1 finishes for each user
● The last user starts late (at 18s), so the test will continue beyond 20 seconds
⚙️ Total Test Duration ≈ (Last user start time + Last user
response time) - (First user start time)
(but could be a bit more because last user starts late)
1️⃣ What “Each Loop Duration” Means
● In JMeter, each loop = the time it takes for one user to complete all samplers
(requests) in the Thread Group once.
● This includes:
1. All HTTP requests or other samplers in that Thread Group
2. Think time / timers (if any)
3. Pre-processors / post-processors / assertions
So “10 seconds per loop” is not a fixed number — it depends on your test plan
and server response times.
🔹 2️⃣ How to Find Loop Duration in JMeter
Method 1: Using “View Results in Table”
1. Add Listener → View Results in Table to Thread Group
2. Run the test
3. Check the “Time” column for each sampler
4. Sum up all samplers in one iteration → gives approximate loop duration per user
Method 2: Using “Summary Report”
1. Add Listener → Summary Report
2. Run the test
3. The “Average” column shows average response time per request
4. Multiply by number of requests per loop → gives loop duration
Method 3: Use a Timer / Stopwatch
● You can manually note the start time of first request and end time of last request for
a loop
● Subtract: Loop Duration = End Time – Start Time
🔹 3️⃣ Practical Example
Thread Group has 3 HTTP requests:
Reques Avg Response
t Time
A 2 sec
B 1.5 sec
C 2.5 sec
●
Loop Duration ≈ 2 + 1.5 + 2.5 = 6 seconds
● If Loop Count = 2 → user takes ≈ 12 sec for 2 loops
If you have timers (think time) → add that to the duration