Testing performance of web page with Apache JMeter

In last article we saw a typical workflow of a browser calling a web page and displaying it for the user.  If you have not read that post please read it here first.

Topics covered in this article:

  1. Step by step method to test single web page in Apache JMeter
  2. Manually creating a test plan in Apache JMeter
  3. Simulating 50 users through Apache JMeter test plan
Let us see what we want to achieve first.  We want to create a Test Plan in Apache JMeter so that we can test performance of one web page say page shown by the URL: http://www.google.com/.  We will need many elements in the JMeter Test plan let us see what are they:
So this is what we shall see when we are done with creating the Test Plan.  We have to start with a blank JMeter window
Before adding anything more to this window let us change the name of Test Plan.  We can type a new name for the node in the Name text box.  In this version of JMeter the name does not get reflected immediately when you type it in the text box.  You have to change focus to workbench node and back to Test Plan node to see the name getting reflected.
Let us give new name "First Test" to the Test Plan node.
Now we will add our first element in the window.  We will add one Thread Group, which is placeholder for all other elements like Samplers, Controllers, Listeners.  We need one so we can configure number of users to simulate.  The Thread Group represents one set of actions performed by User.
In JMeter all the node elements are added by using the context menu.  You have to right click the element where you want to add a child element node.  Then choose the appropriate option to add.
We will click the Thread Group option and it will get added under the Test Plan (First test) node.
Like we changed the name of Test Plan let us also change the name of Thread Group.  For us this is the element which represents multiple users.  So let us name it "Users".  For us this element means Users visiting the Google Home Page.
Now we have to add one Sampler in our Thread Group (Users).  As done earlier for adding Thread group, this time we will open the context menu of the Thread Group (Users) node by right clicking and we will add HTTP Request Sampler by choosing Add > Sampler > HTTP request option.
This will add one empty HTTP Request Sampler under the Thread Group (Users) node.
 We will need most configuration in this node element, HTTP Request Sampler.  The settings we have to configure are:
  1. Name: we will change the name to reflect the action what we want to achieve
    1. This will will name "Visit Google Home Page"
  2. Server Name or IP: here we have to type the web server name
    1. In out case it is www.google.com
    2. Note http:// part is not written this is only the name of the server or its IP
  3. Protocol: we will keep this blank
    1. That will mean we want HTTP as the protocol
  4. Path: we will type path as / (slash)
    1. This means we want the root page of the server
    2. This also means now the server will decide what page will be sent to us and it is the default page of the web site
After add the HTTP Request Sampler we will need one Listener.  Let us add View Results Tree Listener under the Thread Group (User) node.  This will ensure that the results of the Sampler will be available to view in this Listener node element.
Adding a listener is also same like adding a new node under Thread Group.  Open the context menu and choose Add > Listener > View Results Tree option to add the listener.
With this much of setup we are now ready to run our first test.  Coming back to the configuration of the Thread Group (Users) we have kept it all default values.  This means JMeter will execute the sampler only once.  It will be like a single user and only one time.
This is similar to like a user visiting a web page through browser, only here we are doing that through JMeter sampler.  We will execute the test plan using Run > Start option.
Apache JMeter asks us to save the test plan in a disk file before actually starting the test.  This is important if we want to run the test plan again and again.  If we say not to save by clicking No option it will run without saving.  Let us save it first so we can reuse it again.

We have kept the setting of the thread group as single thread (that means one user only) and loop for 1 time (that means run only one time), hence we will get result of one single transaction in the View Result Tree Listener.

This means JMeter was successful in fetching the web page at the given URL just like a browser.  It has stored all the headers and the response sent by the web server and ready to show us the result in many ways.

Let us take a closer look at the three tabs available in the View Result Tree Listener view. 

The first tab is Sampler Results.  It shows JMeter data as well as data returned by the web server.  Usually browsers hide this data from us as it is not related to showing the web page.  This data is utilized internally by the browser, for example when there is a Response Code: 404 then the browser shows a page not found error page, and when the Response Code is 200 the browser shows the received web page HTML.

The second tab is Request, where all the data which was sent to the web server as part of the request is shown.

The last tab is Response data.  In this tab the listener shows the data received from server as it is in text format.  It also have facility to show the data in XML, HTML formats but that will be just the data in other way (no JavaScript will be executed).  This may look different that the page actually seen in the browser.

We can select different ways of viewing this response data like as below:
This was just one request but JMeter's real strength is in sending the same request like many users are sending it.  To test the web servers with multiple users we will have to change the Thread Group (Users) settings.

We will set 50 users and these requests will be sent with some delay of (10/50) seconds as we have set the ramp up time to 10.

To visualize the results, a better aggregating listener will be required so we will add Summary Report Listener in the Thread Group node.  Adding Summary Report Listener is similar to adding a View Results Tree Listener.  Just right click on the Thread group node and choose Add > Listener > Summary Report.

We will run the test plan again after adding the Summary Report Listener ans when the test is done we will see the following results.  Your results may be different than mine due to different environments but mostly similar.

This is how we tried testing one single page with JMeter.  The summary report shows values about the measurement JMeter has done while calling the same page as if many users are calling the page.  Let us look at some of the value headings and what they mean:

  • Samples: A sample mean one sampler call.  One request to web page in our case.  So the value of 51 means total 51 web page requests to the page http://www.google.com were made by JMeter 
  • Average: This value is the average time taken to receive the web pages.  In our case there were 51  values of receiving time which were added and divided by 51 and this value is arrived by JMeter.  This value is a measure of performance of this web page.  This means on an average 334 milliseconds time is required to receive this web page for our network conditions.
  • Min and Max: These are the minimum and maximum value of time required for receiving the web page.
  • Std. Dev:  This shows how many exceptional cases were found which were deviating from the average value of the receiving time.   The lesser this value more consistent the time pattern is assumed.
  • Error %: This value indicated the percentage of error.  In our case 51 calls were made and all are received successfully this means 0 error.  If there are any calls not received properly they are counted as errors and the percentage of error occurrence against the actual calls made is displayed in this value.
To check the performance of the web page the average value of receiving the page is an important parameter to check.  
The sample test plan so created in this article is available for download here:

NOTE: This technique of manually adding a HTTP Request Sampler is only useful in testing a single web page.  This means when we visit the home page of any web site this technique works best.  When we want to test a sequence of web pages, and when there involve web sites created by complex frameworks like ASP.NET, Java JSF etc then recording the sequence of web pages using HTTP Proxy component is useful.  The recording of web pages sequence with HTTP Proxy component will be covered in a post very soon on this blog.

Thanks for reading

with regards
JMeter Expert Blog Team


Big thanks to this blog author

Latest blog

Web Analytics