📘 Section 2: Recording the JMeter Scripts
✅ 1. Recording the Application Under Test with JMeter
🔧 Why Recording is Important:
Helps simulate real user actions (clicks, navigation, etc.)
Automatically generates HTTP requests for each action
Saves time in writing scripts manually
🧰 What You Need:
Apache JMeter
JMeter HTTP(S) Test Script Recorder
Java (JDK) installed
Browser configured to use JMeter's proxy
🔄 How Recording Works:
JMeter acts as a proxy server.
It captures HTTP/S requests between your browser and the server.
These captured requests are saved into a JMeter test plan.
🔍 Steps to Record:
1. Start JMeter:
Launch jmeter.bat (Windows) or jmeter.sh (Linux/Mac)
2. Add Test Script Recorder:
Right-click Test Plan → Add → Non-Test Elements → HTTP(S) Test Script Recorder
3. Add a Thread Group:
Right-click Test Plan → Add → Threads → Thread Group
4. Add HTTP Request Defaults:
(To define domain, port, etc.)
5. Set Port for Proxy (Default: 8888)
Ensure your browser uses this port for HTTP/HTTPS.
6. Install JMeter CA Certificate (for HTTPS recording):
o Start recording → A certificate ApacheJMeterTemporaryRootCA.crt is generated
o Import this into your browser’s certificate store
o Helps JMeter decrypt HTTPS traffic
7. Start the Recorder
Click Start in the Test Script Recorder panel
o Visit your target site
o JMeter records every request into the Thread Group
8. Stop Recording
Once done, click Stop. The test plan is ready for playback.
▶️2. Recording and Playback of JMeter Scripts
Playback Process:
Simply run the recorded script.
JMeter will simulate the same flow by hitting the server with the recorded HTTP requests.
🔁 Modify or Enhance:
You can parameterize values (e.g., login, search terms)
Add assertions to validate responses
Use timers to simulate user think time
📌 Best Practices:
Remove unwanted requests (ads, trackers, etc.)
Rename samplers clearly (Login Page, Search, Add to Cart)
Group actions logically for better readability
🌐 3. Recording in Chrome using BlazeMeter Extension
🔧 Why Use BlazeMeter Chrome Extension?
No need to configure proxy settings
No hassle with certificates for HTTPS
Lightweight and browser-based
🔄 Steps:
1. Install BlazeMeter Plugin from Chrome Web Store
Link: https://chrome.google.com/webstore
2. Click on Extension → Start Recording
Perform the scenario on your website/app
3. Stop Recording → Export
Export the recorded file in .jmx format (JMeter format)
4. Open in JMeter
Launch JMeter → File → Open → Load .jmx file
o You now have a full test plan ready to modify and run.
🧠 Real-Time Use Case
Imagine you're testing a login to purchase flow on an e-commerce site:
Start BlazeMeter → Login → Search product → Add to cart → Checkout → Logout
Stop and Export
You now have a test script simulating a real user journey!
Run it with different users and check server behavior under load.
✅ Summary
Task Tool/Step Notes
Record with JMeter HTTP(S) Test Script Recorder Best for full control & customization
Playback Recorded Scripts Use Thread Group in JMeter Helps validate real user flow
Record with BlazeMeter Chrome extension Simpler & no proxy/cert issues
🧪 Section 3: How to Put Load and Analyse
Performance Metrics
Topics Covered:
1. Importance of Thread Group in JMeter
2. Applying Load on Application with Thread Group
3. What are Listeners? & Importance of View Results Tree
4. Listeners to Monitor Load Testing Results
5. Types of Listeners and their Usage in Gathering Performance Metrics
❓Q1. What is the purpose of the Thread Group in JMeter?
Answer:
Thread Group is the starting point of any test in JMeter. It controls:
Number of users (threads) you want to simulate
Ramp-up time (how fast users should be added)
Loop count (how many times each user should repeat)
Option 1 (how fast users should be added) is the best description of the effect.
Option 2 (how much time user should be added) sounds confusing and is wrong,
because it suggests per user, which is not correct — ramp-up is for all users
together, not individually.
JMeter doesn’t just take it as "time only."
It uses that time to calculate the rate at which
users should start.
👉 In one of my projects, I used a Thread Group to simulate 200 users logging into a web portal, with a
10-second ramp-up. This helped us test how the login API handles sudden traffic. If there were no
ramp-up time, JMeter would start all users instantly, which is often unrealistic and might crash the
server.
❓Q2. How do you apply load on an application using Thread Group?
Answer:
Here’s how I did it:
1. Add Thread Group
2. Set:
o Number of Threads (Users) – e.g., 100
o Ramp-Up Period – e.g., 20 seconds (5 users/sec)
o Loop Count – e.g., 2 (each user hits the API twice)
3. Add HTTP Samplers (requests) inside the group
4. Add Listeners to view results
5. Run the test and monitor response time, failures, etc.
This simulates real user behaviour and puts controlled load on the application.
❓Q3. What are Listeners in JMeter and what do they do?
Answer:
Listeners are JMeter components that capture test results and display reports.
They help track:
Response time
Success/failure
Errors
Graphical reports
👉 I often use View Results Tree while debugging and Summary Report or Aggregate Report for final
performance results.
❓Q4. What is the importance of the View Results Tree listener?
Answer:
View Results Tree shows:
Request and response for each sampler
Pass/fail status
Response data and headers
It’s useful when:
You are debugging failures
You want to verify whether requests are hitting the server correctly
You want to analyze raw response
📌 But I usually disable it during heavy load testing, as it consumes a lot of memory and slows down
the test.
❓Q5. Which listeners do you use to monitor load testing results?
Answer:
In real-time load testing, I use:
Summary Report – Gives count, average response, error %
Aggregate Report – Same as summary but with additional percentiles
Graph Results – Visual trends of performance
Backend Listener – To send data to InfluxDB + Grafana dashboards (for live monitoring)
These help identify bottlenecks and monitor application stability under load.
❓Q6. Can you list different types of listeners and what they’re best used for?
Answer:
Listener Name Purpose / Use Case
View Results Tree Debug requests/responses during test creation
Summary Report Quick metrics like average, min, max, error %
Aggregate Report More detailed summary with percentiles
Response Time Graph Shows response time trends
Listener Name Purpose / Use Case
Graph Results Visualize throughput and performance
Simple Data Writer Export results to file (CSV/XML)
Backend Listener Sends data to external monitoring tools
📌 Real usage: I use Summary Report + Aggregate Report for analyzing results and Simple Data Writer
to save logs for later.
❓Q7. What challenges have you faced while using listeners in large tests?
Answer:
In one test with 500 users:
View Results Tree slowed the system and caused JMeter to crash
High memory usage from GUI listeners affected accuracy
How I fixed it:
Disabled GUI listeners during large runs
Used Non-GUI mode and saved results to a file
Visualized data later using reports
🧪 Section 4: Advanced Thread Group Methods for Real
Time Load with JMeter
1. Additional Plugins to set Advanced Load Configuration
2. Concurrency Thread Group & Ultimate Thread Group Usage
❓Q1. What are Advanced Thread Groups in JMeter and why are they used in real-time projects?
Answer:
Advanced Thread Groups (like Concurrency Thread Group and Ultimate Thread Group) are extra
components in JMeter that you get through plugins.
In real projects, we don’t just test with a fixed number of users starting all at once (which is what the
default thread group does). We want to simulate real-world traffic, like:
Gradual increase in users
Holding a consistent number of users
Ramp down slowly to check stability
These advanced thread groups help us mimic actual user behavior on the app and get meaningful
performance results.
1️⃣ Normal Thread Group (JMeter’s default)
Key idea: You tell JMeter how many threads (users) to create and how quickly to start them.
Parameters:
o Number of Threads (users) → how many virtual people you want
o Ramp-up Period (seconds) → how long it takes to start them all
o Loop Count → how many times each user repeats the test
Example:
Threads = 5
Ramp-up = 10 sec
Loop Count = 1
Logic:
5 users need to be started in 10 seconds → JMeter starts 1 user every 10 ÷ 5 = 2 sec
Timeline:
0s → User1 starts (login → browse → logout)
2s → User2 starts
4s → User3 starts
6s → User4 starts
8s → User5 starts
⚠️Problem:
Ramp-up controls only when they start — they may finish at different times, so you don’t get a
constant number of active users. If User1’s script finishes before User5 starts, your “load” isn’t stable.
2️⃣ Concurrency Thread Group (from JMeter Plugins)
Key idea: You say how many concurrent users you want at all times and how quickly to
reach that number.
This fixes the unstable load problem in Normal TG.
Parameters:
o Target Concurrency → exact number of active users you want
o Ramp-up Time → how long to go from 0 to Target Concurrency
o Ramp-up Steps Count → split the ramp-up into equal bursts
o Hold Target Rate Time → how long to keep that exact concurrency
o Iterations → how many loops each user should do (optional)
Example:
Target Concurrency = 5
Ramp-up Time = 10 sec
Ramp-up Steps = 5
Hold Target Rate = 30 sec
Timeline:
0s → Start 1 user
2s → Add 1 (total 2 active)
4s → Add 1 (total 3 active)
6s → Add 1 (total 4 active)
8s → Add 1 (total 5 active)
10–40s → Keep exactly 5 active users running their scripts
💡 If someone finishes early, CTG starts a replacement immediately — so concurrency stays constant.
3️⃣ Ultimate Thread Group (another plugin)
Key idea: You have full manual control over the load shape — you decide exactly when to
add/remove how many users.
Parameters: A table where for each “stage” you set:
o Start Threads Count → number of threads to start in this stage
o Initial Delay → wait before starting this stage
o Startup Time → how long to spread the start of these threads
o Hold Load For → how long to keep these threads active
o Shutdown Time → how long to spread stopping them
Example:
Start Threads Initial Delay Startup Time Hold Load For Shutdown Time
10 0 sec 20 sec 60 sec 10 sec
Start Threads Initial Delay Startup Time Hold Load For Shutdown Time
5 30 sec 10 sec 40 sec 5 sec
Meaning:
1. At 0 sec → Start ramping up 10 threads over 20 sec
2. At 30 sec → Start another 5 threads over 10 sec
3. You now have 15 total for some overlap period, then they finish according to the shutdown
plan
💡 Ultimate TG = most flexible, but you must do all the math and schedule.
Quick Comparison Table
Feature Normal TG Concurrency TG Ultimate TG
Keep constant active users? ❌ No ✅ Yes ✅ Yes (manual)
Ramp-up style Automatic evenly Even or stepped Fully manual
Best for Simple quick tests Realistic steady load Complex custom load shapes
❓Q5. How do you install these thread groups in JMeter?
Answer:
Steps I followed:
1. Open JMeter → go to Options → Plugins Manager
2. In the Available Plugins tab, search for:
o “Concurrency Thread Group”
o “Ultimate Thread Group”
3. Click “Apply Changes and Restart JMeter”
After restart:
Go to Test Plan → Add → Threads → You'll see the new options
Very simple, and it unlocked a lot of flexibility in our test plans.
❓Q6. Why are these thread groups important for performance testing?
Answer:
In real performance testing, your app is not used by all users at once, but rather gradually and
consistently.
These thread groups help by:
Mimicking real production usage
Catching issues under steady load (e.g. DB slowdowns, memory
leaks)
Stress testing peak hours
Creating load test scenarios clients actually care about
In one of my e-commerce projects, the advanced thread group helped simulate Black Friday traffic,
and we discovered that payment gateway API failed at 200 concurrent users.
❓Q7. Can I use multiple advanced thread groups in the same test plan?
Answer:
Yes. I did this in a real project where:
One thread group tested login and browse
Another tested checkout flow
Third one simulated admin dashboard
All ran in parallel to mimic how different types of users interact with the system.
In JMeter you can have multiple Thread Groups in a single Test Plan, and in practice it’s used quite a
lot.
🧪 Section 5: HTTP Cookie Manager to Capture Sessions
In latest JMeter versions (5.x onwards):
HTTP Cookie Manager is NOT added by default.
You still need to manually add it if you want JMeter to handle cookies like a browser.
Typical Case: Login + Cookie
When you successfully log in, the server sends back something like:
Set-Cookie: session_id=abc123xyz; Path=/; Secure; HttpOnly
Your browser stores this cookie and sends it with every request to prove you’re the same
logged-in user.
Without it, the server wouldn’t “remember” you — you’d have to log in again on each page.
Stateless APIs
Mobile apps or APIs often send tokens in HTTP headers (e.g., Authorization: Bearer <token>)
instead of cookies.
✅ 16. Why Do We Need to Add a Cookie Manager in Tests?
Web applications often use cookies to manage sessions and user state.
When a user logs in or performs actions, cookies store:
o Session ID
o Authentication tokens
o User preferences
If you don’t add an HTTP Cookie Manager in your JMeter test:
o JMeter won’t store or send cookies like a real browser.
o Result: Requests won’t maintain session, causing login/session-dependent requests
to fail.
Real browser behavior is simulated using this manager.
👉 Without it, every request is treated as a new user.
✅ 17. Usage of Cookie Manager in JMeter Tests
How to Add:
1. Right-click on the Thread Group → Add → Config Element → HTTP Cookie Manager.
Options in Cookie Manager:
o Clear cookies each iteration (checkbox)
If checked: JMeter will reset cookies after each user iteration.
Helps simulate new user behavior for each loop.
o Use Thread Group naming
Useful in distributed testing.
o Supports Cookie Policy (default: standard)
When to Use:
o While testing flows like:
Login → Dashboard → Add to cart → Checkout
o If you need to preserve session information across multiple requests.
Debug Tip:
o Use View Results Tree listener.
o Check response headers → Look for Set-Cookie.
o If cookies are being sent back and stored correctly, your Cookie Manager is working.
🧪 ✅ Section 6: Assertions in JMeter
✅ What Are Assertions in JMeter?
Assertions are verification points in JMeter used to validate that server responses match expected
outcomes. They help determine whether the test passed or failed based on certain conditions like:
Response text
Status code
Response time
JSON/XML structure or values
📌 Think of Assertions as “checkpoints” to ensure your application is behaving correctly under load.
✅ Why Are Assertions Important in JMeter?
Ensure functional correctness during performance testing
Mark requests as pass or fail
Can be used in CI/CD pipelines for automated test validation
Critical in detecting silent failures under load (e.g., error pages)
✅ Common Assertion Types in JMeter (with Real-Time Use Cases)
Assertion Type Use Case Practical Example
Response Verify content in the response body, Check if the word “Welcome” appears
Assertion headers, etc. after login
Duration
Fail if response time exceeds threshold API must respond in under 2 seconds
Assertion
Check that response is not empty or too
Size Assertion Validate response size in bytes
large
Ensure response contains
XML Assertion Validate structure of XML response
<status>200</status>
JSON Assertion Validate specific fields/values in JSON Check if userId == 123 in API response
Assertion Type Use Case Practical Example
HTML Assertion Validate HTML response structure Check for valid HTML page returned
Validate presence of
XPath Assertion Use XPath to verify parts of an XML
<price>19.99</price>
Advanced/custom validation using Create dynamic rules like: "Fail if count <
JSR223 Assertion
Groovy/Java 10"
✅ How to Add and Use Assertions in JMeter (Quick Steps)
1. Right-click a Sampler → Add → Assertions → [Choose Type]
2. Configure assertion logic (e.g., “contains”, “matches”)
3. Use “View Results Tree” to validate assertion behavior
4. Mark tests pass/fail based on these conditions
✅ Real-Time Scenario for Assertion Use
🧪 Scenario: Test login API and confirm it redirects to the dashboard page
Use Response Assertion to check:
o HTTP code is 200
o Body contains “dashboard”
Use Duration Assertion to ensure it loads in < 3 seconds
🧾 Result:
If dashboard not found → test fails
If duration exceeds 3s → flagged as performance concern
🧪 ✅ Section 7: Samplers & Controllers
Samplers vs Controllers
Samplers: Actually send the request to the server (e.g., login, search flight, book ticket).
Controllers: Decide when, how many times, and in what order the samplers run.
JMeter Samplers
A Sampler tells JMeter what type of request to send to the server.
Think of Samplers as the "actions" a user performs.
Main Samplers and Flight Booking Use Cases
Sampler Purpose Detailed Flight Example Notes
"Search for flights from Most used for
Sends HTTP/HTTPS request
HTTP Request Delhi to New York on 12th REST/HTTP APIs &
to a web server
Sep" web pages
Upload/download files Airline uploads new flight Rare today; used in
FTP Request
from FTP server schedule CSV to server legacy systems
Fetch seat availability from
JDBC Request Execute SQL queries Requires JDBC driver
airline DB
SOAP/XML-RPC Fetch ticket pricing via Needed if backend is
Send SOAP request
Request SOAP-based service SOAP
Publish "Booking
JMS Work with messaging
Confirmation" message to Used in async flows
Publisher/Subscriber queues
queue
Custom Java code Generate dynamic booking Can slow test; use
BeanShell Sampler
execution reference JSR223 instead
Same as BeanShell but Calculate dynamic fare Preferred over
JSR223 Sampler
faster (supports Groovy) discounts before request BeanShell
Connect to airline legacy
Send data over TCP
TCP Sampler mainframe to validate Very specific use case
connection
tickets
Run custom Java test for Not common in load
JUnit Sampler Run unit test classes
payment validation tests
JMeter Controllers
Controllers control how samplers execute — either in order or based on conditions.
They can be grouped into Logic Controllers and Flow Controllers.
TYPES OF CONTROLLERS
A. Logic Controllers
These decide the flow of requests.
1. Simple Controller
Definition: Simple Controller is just a container to organize requests (no extra logic).
Explanation: Like keeping all “Flight Booking” steps in one folder in JMeter for better readability.
Use Case: Group all samplers related to "International Flight Booking" (Search → Select → Pay).
Flights Example:
Simple Controller: "International Flights"
→ Search Flight Sampler
→ Select Flight Sampler
→ Payment Sampler
It keeps things clean but doesn’t affect execution order or count.
2. Loop Controller
Definition: Runs the samplers inside it N number of times.
Explanation: Like a pilot doing the same flight path 3 times for training.
Use Case: Check how booking API performs if the same passenger books 3 times.
Flights Example:
Loop Count = 3
Inside: "Search Flight" sampler
Result: Same search request executed 3 times per user.
3. Once Only Controller
Definition: Runs its samplers only once per thread, even if other controllers loop.
Explanation: Like logging in only once when you enter the airport, even if you take multiple flights.
Use Case: Avoid logging in multiple times unnecessarily during performance tests.
Flights Example:
Once Only Controller:
→ Login Sampler
Loop Controller (5 times):
→ Search Flight Sampler
Here, Login runs only once, but Search Flight runs 5 times.
4. If Controller
Definition: Runs samplers only if a given condition is true.
Explanation: Like, if weather is clear, then take off; else, stay on ground.
Use Case: Conditional execution based on response data or variables.
Flights Example:
If "AvailableSeats" > 0, run "Book Ticket" sampler.
Else skip booking.
5. Transaction Controller
Definition: Transaction Controller measures total time for a set of requests.
Explanation: Like timing the whole "Check-in process" from luggage drop to boarding pass printing.
Use Case: Measure end-to-end booking time (Search → Select → Payment).
Flights Example:
Transaction Controller: "End-to-End Booking"
→ Search Flight
→ Select Flight
→ Payment
JMeter will show total time taken for these combined.
6. Module Controller
Definition: The Module Controller allows you to select and execute a specific module (usually a
group of samplers or controllers) defined elsewhere in your test plan.
Explanation: Like having a shared boarding process used by both Domestic and International flights.
Use Case: Avoids duplicate samplers in big tests.
Flights Example:
Have a “Login Sequence” in one place.
Domestic and International test plans both call that using Module Controller.
7. Runtime Controller
Definition: Runs samplers for a set time instead of a set count.
Explanation: Like flying a route for exactly 10 minutes, no matter how many laps are done.
Use Case: Stress test an API for a specific duration.
Flights Example:
Run "Search Flight" continuously for 2 minutes per user.
8. Throughput Controller
Definition: Controls the percentage of requests that should go to certain samplers.
Explanation: Like 70% passengers go for Economy, 30% for Business class booking.
Use Case: Simulate realistic traffic distribution.
Flights Example:
70% users → Search + Book Economy
30% users → Search + Book Business
9. Interleave Controller
Definition: Runs one sampler from its list in each loop iteration (alternates).
Explanation: Like alternating between two runways each time a plane takes off.
Use Case: Switch between multiple actions in sequence.
Flights Example:
Loop 3 times:
Iteration 1 → Search Flight
Iteration 2 → Check Flight Status
Iteration 3 → Search Flight again
10. Random Controller
Definition: Picks a random sampler each time.
Explanation: Like randomly assigning passengers to check-in counters.
Use Case: Randomize user actions to simulate real-world unpredictability.
Flights Example:
User might either “Search Flight” or “Cancel Booking” at random.
11. Switch Controller
Definition: Runs only the sampler at the index specified.
Explanation: Like telling the plane to use Gate 3 only.
Use Case: Trigger a specific step in a large test plan without changing structure.
B. Practical Real-time Example – Flight Booking Simulation
Scenario:
We want to simulate how people use an airline booking website.
Flow in JMeter:
1. Once Only Controller: Login (only once per user)
2. Loop Controller (5 times): Search for flights
3. If Controller: If flight found → Book ticket
4. Transaction Controller: Measure total booking time
5. Throughput Controller: 80% Economy bookings, 20% Business bookings
6. Module Controller: Reuse "Logout" step in multiple flows
✅ Why so many controllers?
Because in real-world flight booking:
Not every user books a flight (If Controller helps).
Some users search multiple times (Loop Controller helps).
We need to time the whole journey (Transaction Controller helps).
Not all traffic is same (Throughput Controller helps).
We want reusable steps (Module Controller helps).
🧪 Section 8: Timers
1. What is a Timer in JMeter?
Definition:
A Timer in JMeter is used to introduce a pause (delay) between requests.
By default, JMeter sends requests as fast as possible without waiting.
In real life, users take time to think, fill forms, or read pages — timers help simulate that
human behavior.
Why Timers Matter:
o Prevents overloading the server with unrealistic back-to-back requests.
o Simulates real user interaction and network delays.
o Helps get realistic performance metrics.
2. Types of Timers (with Flight Booking Examples)
2.1 Constant Timer
Definition:
Adds the same fixed delay before each request.
Explanation:
It’s like telling JMeter, “Wait exactly X milliseconds before making the next request.”
Samplers in order: A → B → C
Constant Timer placed under Sampler A
So in your case
Timer under Sampler A → affects only Sampler A.
It means: before executing Sampler A, JMeter will wait for the delay you set in the Constant
Timer.
Samplers B and C will execute immediately after, without that timer (unless they have their
own).
2.2 Uniform Random Timer
Definition:
Adds a delay picked randomly between a minimum and maximum range.
Flight Example:
Searching for flights — some users take 2–5 seconds to pick a flight after search results
appear.
o Uniform Random Timer Min: 2000 ms, Max: 5000 ms.
2.3 Gaussian Random Timer
Definition:
Adds a random delay based on a Gaussian distribution (bell curve: most delays around the
average, few extremes).
Explanation:
Most real-world delays cluster around an average value, with occasional faster or slower
cases.
2.4 Poisson Random Timer
Definition:
Adds random delay based on a Poisson distribution, often used for event-based arrival times.
Explanation:
Suitable for simulating requests that happen sporadically but follow a probability pattern.
Use Case:
o Useful for simulating event-driven traffic (e.g., booking requests during peak sale
hours).
Flight Example:
Simulating last-minute booking surges when a discount is announced — requests come
randomly but in bursts.
2.5 Constant Throughput Timer
Definition:
Controls how many requests per minute JMeter sends.
Explanation:
Instead of a fixed delay, it adjusts pause time dynamically to maintain a target throughput.
Use Case:
o When you need to maintain a consistent request load over time.
Flight Example:
A corporate booking system should handle 120 bookings per hour steadily for SLA testing.
o Set throughput = 120 requests/minute.
2.6 Synchronizing Timer
Definition:
Pauses threads until a set number of users are ready, then releases them all at once.
Explanation:
Simulates multiple users hitting the server at the exact same moment.
Use Case:
o Perfect for stress testing a specific point in the system.
Flight Example:
When a flash sale opens at midnight, 500 users try to search flights at the exact same
second.
o Synchronizing Timer Count = 500.
2.7 BeanShell / JSR223 Timer
Definition:
Custom timer where you can write code to define complex delay logic.
Explanation:
For advanced cases where delay depends on variables, conditions, or dynamic calculations.
Use Case:
o Fully customized think time logic.
Flight Example:
If delay depends on the number of seats available:
o If seats > 50 → Delay = 2 sec
o If seats < 10 → Delay = 6 sec.
3. How Timers Work in JMeter
By default, Timers apply to the sampler(s) within the same scope.
If placed under a Thread Group, they apply to all samplers in that thread group.
Multiple timers add up their delays.
They do not run in parallel — delays are sequential.
4. Real-Time Strategy for Timers in a Flight Booking Load Test
Imagine you’re testing a flight booking web app for 200 concurrent users:
1. Search Flights (GET) – Uniform Random Timer (2–5 sec) → simulate users scanning results.
2. Select Flight (POST) – Gaussian Random Timer (~4 sec) → simulate seat selection time.
3. Passenger Details (POST) – Constant Timer (3 sec) → simulate fixed typing delay.
4. Payment Gateway (POST) – Synchronizing Timer (50 users) → simulate bulk checkout at sale
start.
5. Booking Confirmation (GET) – No delay → as payment redirects instantly.
5. Summary Table of Timers
Timer Name Definition Best Use Case Flight Booking Example
3 sec pause before
Constant Fixed delay before requests Predictable think time
booking
Simulate varied user Flight search delay 2–5
Uniform Random Random delay in range
speeds sec
Delay with average +
Gaussian Random Realistic human delays Seat selection avg 4 sec
deviation
Random delay from Last-minute booking
Poisson Random Event-based traffic
Poisson surge
Constant Maintain requests per
Steady SLA testing 120 bookings/hour
Throughput minute
Wait until X users, then
Synchronizing Simultaneous load spike Midnight flash sale hit
release
Delay based on seat
BeanShell / JSR223 Script-based custom delay Complex, variable delays
count
🧪 Section 9: Regular Expression & its importance
Why we need Regular Expression Extractor in JMeter
👉 Reason: Sometimes we want to pull out a part of the server response (text, number, ID, code, etc.)
for checking or using later. Regex Extractor is like a “scissor” that cuts only the part you need.
Example
Response text:
Welcome, your booking number is #BKG12345.
Regex Extractor:
Reference Name: booking
Regex: #BKG(\d+)
Template: $1
Match No.: 1
Result:
${booking} = 12345
Even if you don’t reuse it later, you could use it in an Assertion to verify that the number exists.
Practical Example on Flight Search with Regex Extractor
Response snippet:
<button data-flight-id="FL123">Book</button>
<button data-flight-id="FL456">Book</button>
Regex Extractor:
Reference Name: flightId
Regex: data-flight-id="(FL\d+)"
Template: $1
Match No.: -1 (means all matches)
Result variables created:
${flightId_matchNr} = 2
${flightId_1} = FL123
${flightId_2} = FL456
👉 This way, you can “grab” all flight IDs from the search page.
30. Combining multiple expressions into Single Extractor
👉 Instead of creating two separate extractors, you can capture two values with one regex.
Response snippet:
<input type="hidden" name="csrfToken" value="abc123">
<input type="hidden" name="formId" value="F-98765">
Regex Extractor:
Reference Name: formVars
Regex: csrfToken" value="([^"]+)".*?formId" value="([^"]+)"
Template: $1|$2
Match No.: 1
Result:
${formVars} = abc123|F-98765
${formVars_g1} = abc123
${formVars_g2} = F-98765
👉 So you can either use both together or separately using _g1, _g2.
Great 👍 Here’s a Regex Cheat Sheet for JMeter that you can keep handy.
I’ll focus on commonly needed patterns you’ll actually use in testing.
🔹 Regex Cheat Sheet for JMeter
1. Numbers
Any number → \d+
Example match: 12345
Exact length (5 digits) → \d{5}
Example: 54321
Decimal number → \d+\.\d+
Example: 45.67
2. Words & Text
Any word (letters only) → [A-Za-z]+
Alphanumeric (letters+digits) → [A-Za-z0-9]+
Word with underscore → \w+
3. Emails
Basic email → [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}
Example:
[email protected]4. IDs / Tokens
UUID (36-char, like csrf tokens) → [a-f0-9\-]{36}
Example: 5d12a0b7-6b0a-4e16-9af8-0c1f5e0abc12
Session ID (letters & numbers) → [A-Za-z0-9]+
Flight IDs (e.g. FL123) → FL\d+
5. HTML Attributes
Hidden input value
Regex: name="([^"]+)"\s+value="([^"]*)"
o Group 1 → Field name
o Group 2 → Field value
Button data-id
Regex: data-id="([^"]+)"
Example match: 12345
6. JSON Fields
(Regex works, but JSON Extractor is better. Still, useful to know)
Simple string field
Regex: "username"\s*:\s*"([^"]+)"
Number field
Regex: "price"\s*:\s*(\d+)
Multiple IDs
Regex: "id"\s*:\s*"([^"]+)" (with Match No. = -1)
7. Web URLs
Full URL → https?://[^"\s]+
Capture only domain → https?://([^/]+)
8. Special Cases
Extract text between two words
Regex: Start(.*?)End
o Captures everything between Start and End
Match case-insensitive
Add (?i) in front.
Example: (?i)success matches Success, SUCCESS, etc.
🔹 Tips for JMeter
Always put what you want in ()` (capture group).
Use .*? instead of .* → matches only as much as needed.
In Extractor:
o $1 → first group
o $2 → second group, etc.
With Match No. = -1, you get arrays: ${ref_1}, ${ref_2}, … and ${ref_matchNr}.