With this tutorial we will touch the bare minimal components of JMeter and test performance of a website's home page.
Test Objective: Testing the average load time of the home page of your web site with first 10 concurrent users and then 50 concurrent users and finally 100 concurrent users.
Test Execution: We will execute this test in three phases, and record the average response time for each load.
Preparing the Test Plan:
We will now prepare the test plan using Jmeter step by step
- Start JMeter GUI.
By default a new Test Plan will be available to start with , Rename the test plan name to "Website performance test plan" as shown on the picture below
- We will now create a thread group. Each Thread Group has a number of threads or users ( think threads as users since threads can execute concurrently to simulate concurrent users ), which executes a task. We can configure a number of threads or users to execute the same task concurrently. We will discuss about task in the next step , but now lets create a thread group, number of threads ( users ) .
Right Click on the "test plan" created in the 1st step , and "Add"->"Threads ( users)"-> "Thread Group", and fill the form as below in the picture
As you noticed already , in the Thread Properties field set we have the Number of Threads( users) set to 10, which means is that when we starts executing the test plan , we will have10 threads or users who will be executing the task given to it. The Ramp-up Period ( in seconds ) which is set to 0 represents these threads will execute concurrently. The Loop Count is set to 2 meaning that , each thread will execute twice. Having "forever" is obvious , but we have not done it here.
- Now we have 10 threads / users to run our task , but we have not yet defined the task . Lets do that .
Our threads or users need to send a request to your home page ( website ) . And to let this task has to be assigned to the thread group. There are so many different tasks are available that can be assigned to the thread group , but we are interested in sending http request. And sending http request task or in JMeter terminology sampler.
Right click on the thread group created in step 2, and "Add"->"Sampler"->"Http Request"
The interface gives you the following fields, but we are interested the following.
HTTP Request Name: Home Page request ( Just a name to identify the sampler )
Server name or Ip: localhost [ explanation: is where my web application is running, you can choose google.com ]
Port number: 8081 [ Usually 80 , for web sites, but since my web app is running on 8081 port I have chosen this. Lets say you choose google.com as server name , you can give 80 as port]
Http Request , Implementation: HttpClient4 , however you could choose any other options,
Method : Get, ( since all page request to web sites are GET )
Path: /index.php ( My Home page is at /index.php , but for google.com it is just / )
My Screen looks as below.
- By this step our plan is ready to execute and should run. How do we get to see the result which we are interested in ; the average time ?
We need a "Listener" . A listener is as the name suggests listens to the test result and gives us different visual and non-visual ( statistical) clue about the results.
Lets add a listener to the Http request , from the last step.
Right click on the Http Request and "Add"->Listener->"Summery report"
- You can save the test plan for the future use.
- Now lets run the test plan,click on the run icon from the tool bar, once finished click on the summery report node to see the summary.
In end , few points to the reader, if you want to test for 50 users go ahead and change the value in the thread count in the 2nd step and re-run the test plan. The Summery report will accumulate the data from the previous run, You can always clean the previous run data if you wish to by clicking on the clear and clear all command icons from the toolbar.