1.What is Apache JMeter?
Answer:
JMeter is an open-source tool used for performance testing, load testing, and functional testing of web applications, databases, FTP servers, and more.
Real-time example:
A bank wants to test if their online transaction portal can handle 10,000 concurrent users. JMeter can simulate that load and measure server response.
2. What are the main components of a JMeter Test Plan?
Answer:
- Thread Group
- Samplers
- Listeners
- Timers
- Assertions
- Configuration Elements
- Logic Controllers
Example:
In a test plan simulating login and balance check:
- Thread Group simulates users.
- HTTP Request samplers simulate login and balance check.
- Listeners collect results.
3. What is a Thread Group in JMeter?
Answer:
It defines the number of virtual users and the ramp-up period (time to start all users).
Example:
You want to simulate 100 users logging in over 10 seconds. Set Number of Threads = 100
, Ramp-Up = 10
.
4. What is a Sampler in JMeter?
Answer:
A Sampler sends requests to the server and waits for the response. Common samplers include:
- HTTP Request
- JDBC Request
- FTP Request
Example:
An HTTP Request Sampler sends a GET request to https://myapp.com/login
.
5. What is a Listener in JMeter?
Answer:
Listeners are used to view and analyze results, like:
- View Results Tree
- Summary Report
- Aggregate Report
- Graph Results
Example:
You use Summary Report to monitor average response time, throughput, and error % after a load test.
6. How do you parameterize inputs in JMeter?
Answer:
Using CSV Data Set Config, you can feed data (e.g., usernames, passwords) from a CSV file to make the test dynamic.
Example:
Login with 50 different users by storing usernames and passwords in users.csv
.
7. How does JMeter simulate real-world delays between user actions?
Answer:
Using Timers, especially:
- Constant Timer
- Gaussian Random Timer
- Uniform Random Timer
Example:
Add a 3-second delay between login and dashboard navigation to mimic user behavior.
8. What are Assertions in JMeter?
Answer:
Assertions are used to validate responses. Common types:
- Response Assertion
- Duration Assertion
- Size Assertion
Example:
Check if the word тАЬWelcomeтАЭ appears in the response body after login.
9. What is a Ramp-Up Period in JMeter?
Answer:
Ramp-up defines the time over which the total number of users will be started.
Example:
With 100 users and 10 seconds ramp-up, JMeter starts 10 users per second.
10. How do you monitor server performance while running JMeter tests?
Answer:
- Using JMeter Plugins like PerfMon to monitor CPU, memory, disk, and network usage.
- External monitoring tools like Grafana, InfluxDB, or New Relic.
Example:
Use PerfMon Server Agent on your app server to track CPU spikes during peak load.
11. What is Throughput in JMeter?
Answer:
Throughput is the number of requests per unit time (e.g., requests/second).
Example:
If 6000 requests are processed in 1 minute, the throughput is 100 requests/second.
12. How do you reuse requests across multiple test cases in JMeter?
Answer:
Use Module Controller or Test Fragment to modularize and reuse requests.
Example:
Login steps can be placed in a test fragment and reused across multiple scenarios like balance check, transfer funds, etc.
13. How do you handle sessions or cookies in JMeter?
Answer:
Use the HTTP Cookie Manager to manage cookies across requests just like a real browser.
Example:
After login, the session cookie is saved and reused for dashboard navigation.
14. What are Logic Controllers in JMeter?
Answer: Logic Controllers manage request execution flow, e.g.:
- If Controller
- Loop Controller
- While Controller
- Switch Controller
Example:
Use a Loop Controller to retry login up to 3 times if the response is failed.
15. What is Correlation in JMeter?
Answer:
It refers to capturing and reusing dynamic values (like session IDs) from server responses.
Tool: Regular Expression Extractor or JSON Extractor.
Example:
Capture a dynamic token from login response and use it in a subsequent API call.
16. What is the difference between Response Time and Latency in JMeter?
Answer:
- Response Time: Total time to receive the full response.
- Latency: Time until the first byte is received.
Example:
For an API, if latency is 200ms and response time is 600ms, the server started responding quickly but took time to send full data.
17. Can JMeter be used for API testing?
Answer:
Yes. JMeter supports REST and SOAP API testing using HTTP Samplers and Header Manager.
Example:
Send a POST request to api/orders
with JSON payload and assert the status code is 201.
18. How do you run JMeter tests in non-GUI mode?
Answer: Use command-line execution:
jmeter -n -t testplan.jmx -l results.jtl
Example:
Run load tests on a Linux server via cron job using JMeter CLI.
19. What is distributed testing in JMeter?
Answer:
Running tests across multiple load generators (slaves) controlled by a single master to simulate high user load.
Example:
Simulate 10,000 users using 5 slave machines (each handling 2,000 users) controlled from one master.
20. How do you analyze JMeter results?
Answer:
- Use Listeners like Aggregate Report, Summary Report, Graph Results.
- Export
.jtl
file to Excel for detailed analysis. - Integrate with Grafana + InfluxDB for real-time dashboards.
Example:
After a 1-hour test, analyze response times, error %, and throughput to identify bottlenecks in the checkout process.