Web Performance Test Using Apache Jmeter

For a web application, potential to handle high load is a crucial factor. Performance testing is a big challenge for web application developers to determine the ability of the application to handle the high traffic or handling large amount of requests. There are number of tools available for analysing overall server performance under heavy load. Here we are about to discuss Apache Jmeter, a fabulous load testing tool from apache.
Using jmeter we can simulate concurrent access of multiple user to the web service. So we can Identify the maximum number of users that our website can handle. Another main feature of Jmeter is the availability of various graphical representation of analysis reports, which is useful for identifying the performance very easily.
Now let’s take a look at how we can create a performance test plan of a webservice using Jmeter.
- Install Jmeter fromhttp://jmeter.apache.org/download_jmeter.cgi
- Start Jmeter.
Now you can see a GUI with an empty Test Plan. This Test Plan contains different test components for load testing.
Now, we will add some of this component into our test plan:
1. Adding Thread Group
Right click on the Test Plan and add a new thread group: Add->Threads (Users)->Thread Group
Now in this Thread Group control panel, there is some important properties that affects load testing.
- Number of Threads (users) : The number of requests or users connect to the target website.
- Ramp-Up Period (in seconds) : The time delay for sending the requests to the website. It simply tells the Jmeter how long to delay between starting each user. For example, if you enter a Ramp-Up Period of 5 seconds, JMeter will start all of your users by the end of the 5th second.
- Loop Count : Number of times test should be executed.
- Add Http Request Defaults
This config element is used to set default values for our test plan. This element is useful when we want to send multiple Http request to same server as part of our test. The Http Request defaults elements does not tell the Jmeter to send an Http request, it simply defines the values that used by http request later. To add Http Request Default to Thread Group ,
Right Click on Thread Group ->Add->Config Element->HTTP Request Defaults.
In Http Request Defaults, fill in the web server name or IP address of the server you want to test. By giving this servername or IP there will be a default server for rest of the items.
3. Adding Http Requests
To add http request to the test plan , Right click on Thread Group -> Add -> Sampler -> Http Request
Then select the HTTP Request element from tree and edit the properties,
Provide a name for the request and give the path in which the request is sent. We don’t need to include the server name because we have already done it on HTTP Request defaults elements.Also we can provide the parameters and their values here in the table under parameters tab.
4. Adding Listener To View The Test Results
The final element you need to include in your test plan is a listener which enables you to save the test results data in the file and also provides you with a visual of test results as table, graph etc.
Here, we are adding a listener which will display the test results in table format. To add this listener ,
Right click on Thread Group ->Add ->Listener -> View Results In Table.
Then please save location which you wish to save the test result data.
Also you can manage the elements you want to save in the output file.
5. Run Test Plan
To execute your test plan please click on the green play button on toolbar of Jmeter window or click Run->Start on menu bar. On executing the test we can view the results in table format in Vire Results In Table section. Like as follows,
From the result table, you can see the status of each request as well as the sample time & latency time. Here we are considering these two fields only because these are the values we need to use for analysing our website performance.
Latency time is, number of seconds taken to get the first initial response from the server for each request and Sample time is the time taken by the server to fully serve the request.
You can run this plan by changing the number of requests and Ramp-up time period so that you can identify the reasonable load that can be handled by your website.