Using JMeter for Performance Testing
Performance testing, a non-functional testing technique performed to determine the system parameters in terms of responsiveness and stability under the various workloads.
Performance testing measures the quality attributes of the system, such as scalability, reliability, and resource usage.
Performance Testing Process:
The following image shows you performance testing process
Attributes of Performance Testing :
- Scalability: Scalability Testing is a non-functional test methodology in which an application’s performance is measured in terms of its ability to scale up or scale down the number of user requests or other such performance measure attributes.
- Reliability Testing : Checks whether the software can perform a failure-free operation for a specified period of time in a particular environment.
- Resource utilization: is a way to track how busy various resources of a computer system are when running a performance test.
Performance Testing Tools
JMeter can discover the maximum number of concurrent users that your website can handle.
JMeter provides a variety of graphical analysis of performance reports.
JMeter Performance Testing includes :
- Load Testing : Modeling the expected usage by simulating multiple users access the Web services concurrently.
- Stress Testing : Every web server has a maximum load capacity. When the load goes beyond the limit, the web server starts responding slowly and produce errors. The purpose of the Stress Testing is to find the maximum load the webserver can handle.
The figure below shows how JMeter load Testing simulates the heavy load :
Installation and Configuration of JMeter
- We are doing a performance analysis of Google.com for 1000 users
- Before testing the performance of the target web application, we should determine:
- Normal Load : Average number of users visit your website
- Heavy Load : The maximum number of users visit your website
- What is your target in this test?
Here is the roadmap of this practical example
Add Thread Group :
- Start JMeter in your system.
- Select Test Plan on the Tree.
- Add Thread Group to the Test Plan.
- In the Thread Group control panel, enter Thread Properties as follows:
- Number of Threads : 100 (Number of users connects to the target website: 100)
- Loop Count : 10 (Number of time to execute testing)
- Ramp-Up Period : 100
The Thread Count and The Loop Counts are different :
- Ramp-Up Period tells JMeter how long to delay before starting the next user. For example, if we have 100 users and a 100-second Ramp-Up period, then the delay between starting users would be 1 second (100 seconds /100 users)
Adding JMeter Elements :
- Now we determine what are the JMeter elements in this test plan.
- The elements are:
- HTTP request Default: This element can be added by right-clicking on the Thread Group and selecting:
Add -> Config Element -> HTTP Request Defaults.
- In the HTTP Request Defaults control panel, enter the Website name under test.
Add HTTP Request :
- Right-click on Thread Group and select:
Add -> Sampler -> HTTP Request
- In HTTP Request Control Panel, the Path field indicates which URL path you want to test in the Google domain.
- For example, if you enter the calendar in the Path field.
- JMeter will create the URL request
http://www.google.com/calendar to Google server.
- If you keep the Path field blank JMeter will create the URL request
http://www.google.com to Google server.
- In this test, you keep the Path field blank to make JMeter create the URL request http://www.google.com to Google server.
Adding Graph result :
- JMeter can show the test result in Graph format.
- Right-click on Test Plan, Add -> Listener -> Graph Results.
Run Test and get the test result:
- Press the Run button (
Ctrl + R) on the Toolbar to start the software testing process.
- Once you click on the Run button, you will see a pop-up message to save the file, click on yes.
- Next, select the destination folder to save the file.
- You will see the test result display on the Graph in real-time.
- The picture below presents a graph of a test plan, where we simulated 100 users who accessed on website www.google.com.
- To analyze the performance of the webserver under test, you should focus on 2 parameters: Throughput, Deviation.
- Throughput: is the most important parameter. It represents the ability of the server to handle a heavy load. The higher the Throughput is, the better is the server performance.
- In this test, the throughput of the Google server is 1,491.193/minute. It means Google servers can handle 1,491.193 requests per minute. This value is quite high so we can conclude that the Google server has good performance.
- The deviation is shown in red: it indicates the deviation from the average. The smaller the better.
- Lets compare the performance of the Google server to other web servers.
- This is the performance test result of website http://www.yahoo.com/ (You can choose other websites)
- The throughput of a website under test http://www.yahoo.com is 62.157/minute.
- It means this server handle 65.157 requests per minute, lower than Google.
- The deviation is 925, much higher than Google (109). So we can determine the performance of this website is less than a Google server.
NOTE: The above values depend on several factors like the current server load at Google, your internet speed, your CPU power, etc. Hence, it's very unlikely that you will get the same results as above. So don't panic!