Introduction to JMeter - Performance Test Tool
As name suggest, performance test is a practice conducted to test the system response and stability under particular workload. This is as important as we do the functional test where we audit the system to be stable and reliable for end users.
In order to achieve the performance test for any given system there are many open source and paid tools to assure performance of the system. In this article I'll be referring to Apache JMeter - an open source java application designed to load test functional behavior and measure performance of the system.
Before proceeding to the performance test let us understand some of the basic definitions which are almost used during performance test
Connection Time: It's a time taken to connect to server from client. Imagine there is a request made from the client, here the client request could happen via web application from different browsers/mobile apps/desktop apps or so on. Now Connection Time is the time taken to the client to connect to the server via TCP/IP protocol.
Response Time: It's a time taken to get the response from the server. Imagine client has requested to get some data from the server and the response from the server to fetch the data to the client is 25ms which is noting but the response time from the server. Response can be in the form of different packets.
Throughput: Indicates the number of TPS (Transactions Per Second) an application can handle. Imagine the RT from the system which is coming back to the client can be in the form of different packets, now throughputs could be determined as the total number of transactions or requests in a given time
Bottleneck: Single part of the system that prevents further processing or decreases the performance of whole system
Capacity: Degree to which a system can perform data processing until performance degrades
Concurrence: Number of simultaneous virtual users driving transactions across user journey or it could also be number of synchronised transactions happen at exactly same point
Load Testing: Test behaviour of the system or component
The above are some of the important terminology which are used while performing load testing. However like functional test plan, even performance test also have the KPI-Key Performance Indicators which has requirements or test plan data like Page Load Time, Number of TPS, Maximum average CPU usage, Response Time, Memory allocations and hardware to perform performance test. Using KPI's as a bench mark the products stability, reliability and scalability can be verified with load, stress, spike and soak testing via JMeter.
Recording HTTP and HTTPS scripts in Using JMeter
JMeter as a tool provides user to record the scripts and perform different tests for the product. As we all know the interactions (request and response) of any applications will happen over the network. Our first criteria is to listen those interactions and record. In order to achieve this we need a proxy to listen the interactions made between the client and server. Making JMeter as a proxy sever will help us to record all the packets flow via JMeter proxy.
Pre-Conditions:
- Make sure latest Java is installed on your system
- Make sure JMeter is saved in any directory of your system
- Make sure all the network packets are listening via localhost:8888 in your system where 8888 is JMeter default port
- Make sure JMeter Root CA certificate is installed and trusted
Steps:
- Open JMeter
- From JMeter, Right click on TestPlan > Add > Non - Test Elements > HTTP(S) Test Script Recorder
- Click on "HTTP(S) Test Script Recorder" and make sure port is configured to default (as mentioned in Pre-Condition 3) in Global Settings
- Click on "Test Plan Creation" and make sure "Target Controller" selected as Test Plan > HTTP(S) Test Script Recorder. This will make sure that the target is listening to script recorder
- Now click on "Start" button
- Click on "OK" button on Root CA Certificate modal popup
- Open chrome browser and load any HTTP/HTTPS url
- Observe the network calls on JMeter
Conclusion: From the above steps user can record all HTTP/HTTPS network calls which is as similar as user seeing the network calls from browser developer tools > networks tabs. Based on the KPI, user can choose the network call and perform different performance test by increasing the virtual users via Thread Counts