fbpx

Avoiding to load test any web application could be risky. Why? Because if the program is exposed to an excessive load, the entire system can fall on its knees, offering nothing but a waste of time and resources. That’s why load testing is one of the crucial parts of performance testing which is necessary to be applied.  Luckily, there are different load testing tools available that ease the process. However, many developers and testers prefer using JMeter to do this job. So, dive in to find out more about JMeter with the help of a few load testing examples.

 

What is JMeter?

Developed using 100 percent Java language, ‘JMeter’ or ‘Apache JMeter’ is a strong and highly-featured load testing tool currently available. This program can load test both dynamic and static resources by generating concurrent users to create a real-life testing environment to recognize the bottlenecks in any web or mobile application. Furthermore, JMeter offers a complete report after analyzing the source and the results can be examined through various modes of interpretations.

 

What is Load Testing?

Load testing, as mentioned earlier, is a way to assess any application’s behavior when applied with different loads (users/traffic). In simple words, load testing helps understand how a program (let’s assume a website “abc.com”) would perform when 20 users are using the platform at one time? Likewise, what changes in the performance you get if the number of users increases from 20 to 100? Or even thousands of users?  Load testing is applied to identify errors made in the development process, which are responsible for a particular software’s poor performance or failure. This helps developers amend mistakes to make sure everything runs smoothly. Contrarily, you should know that load testing can sometimes requires a professional and experienced team to obtain correct outcomes.

 

5 JMeter Load Testing Cases

Here are five JMeter load testing examples that will help you grasp the process. Each example includes a different application to increase your understanding. Also, every JMeter load test requires a proper test plan. Assuming that you have already installed JMeter on your workstation, you can learn from these examples to test the application on your own. However, it is recommended to take help from the experts, in case you have no prior expertise.  Let’s get started.

 

Example 1 – Load Testing for Google

In the first example, you are about to see the analysis the testers made for Google.com using JMeter when there are 100 expected users.

 

Test Plan and Result

 

Step 1: Adding Thread Group

Open JMeter and right-click on the ‘Test Plan’ option. Hover on ‘Add’ and ‘Threads’ (users), and select ‘Thread Group’. You will be directed to a control panel, where you are required to add ‘Thread Properties’.

Test Plan > Add > Threads > Thread Group

Enter ‘100’ in ‘Number of Threads’ with ‘Loop Count’ of 10 and ‘Ramp-Up Period’ of 100.  But wait! Remember the terms. The number of threads explains the number of users using the platform (in this case google.com). The loop count defines how many times the test would be executed. And the ramp-up period informs that after what interval a new user should be added.  So, this example is for load testing through JMeter when there 100 users, which will be included after every 100 seconds delay.

 

Step 2: Adding Elements of JMeter

Here, the testers determined the JMeter elements. So after creating a Thread Group, you have to select the ‘HTTP Request Defaults’ option. To do that, right-click on thread group, hover on ‘Config Element’, and then choose the ‘HTTP Request Defaults’. Then, you have to add the server name or IP address (in this case, http://www.google.com).

Thread Group > Config Element > HTTP Request Defaults

After that, right-click on ‘Thread Group’, hover your cursor on ‘Add’ then hover on ‘Sampler’, and then ‘HTTP Request’. And if there is any specific path to test, then fill the ‘Path’ field in HTTP Request Control Panel. For example, entering the ‘calendar’ in the field to let JMeter create the URL request (http:www.google.com/calendar) to Google server.

Add > Sampler > HTTP Request

But for this example, the testers have left the path field blank, and the information is just for your knowledge building.

 

Step 3: Add Graph Results

Once done, again select ‘Add’, hover on ‘Listener’, and choose ‘Graph Results’ to receive test results in the form of graphics.

Add > Listener > Graph Results

 

Step 4: Test and Result Interpretation

After carefully completing all the steps, click on ‘Run’ from the Toolbar to begin testing the program (Google). Soon, you will see the test results through a graph in real-time.  When the test is finished, you will see statistics in different colors at the bottom of JMeter’s interface. Each color has a meaning. For instance:

Blue: Average of samples sent

Black: Total number of samples sent

Green: Throughput rate that shows the number of requests (traffic/users) the server has tackled in every minute.

Red: The standard deviation

Remember, you have to analyze Throughput (Green) and Deviation (Red) in all the examples. Why? It is because Throughput is the most essential parameter that represents the capacity of a server when it comes to handling heavy load. So, higher Throughput and lower deviation means the server has a remarkable performance.

 

JMeter Graph Results_Google

 

Therefore, in this JMeter Load Testing example, Google’s Throughput is 1,491.193 per minute. This signifies that Google servers can tackle 1,491.193 requests/minute. And the deviation is 577. Hence, it is demonstrated that a Google server is exemplary and can bear maximum load.

 

Example 2 – Load Testing for Yahoo

After Google, let’s load test Yahoo through JMeter by following the same steps as mentioned in the first example with a similar test plan (100 ‘Number of Threads’, 10 ‘Loop Count’ and 100 ‘Ramp-Up Period’).

 

JMeter Graph Results_Yahoo

 

As going through the entire method, the results obtained for Yahoo are:

  • Throughput = 867.326 per minute
  • Deviation = 2689

It means the server can handle only 867.326 requests every minute. Also, the deviation is extremely higher (2689). Yahoo server cannot tackle excessive traffic, especially if we compare it with Google. Therefore, the results indicate that Yahoo’s performance is not ideal compared to Google.

 

Example 3 – Load Testing for a Demo PetStore

 

This is an example is of a demo pet store site (JPetstore).

 

Test Plan and Result

Step 1: Adding Thread Group

The first step is similar to Example 1. So, open ‘Test Plan’ in JMeter and select ‘Thread Group’.

Test Plan > Add > Threads > Thread Group

Then enter the following values in ‘Thread Properties’.

  • Number of Threads (users) = 20
  • Ramp-UP Period (in seconds) = 120
  • Loop Count = Checked to ‘Forever’

 

Step 2: Adding Elements of JMeter

Click on the ‘HTTP Request Defaults’ option (as mentioned in Example 1), and add the server name or IP address (http://localhost:8080/actions/Catalog.action).

Thread Group > Config Element > HTTP Request Defaults

Note: JPetstore is a demo site and it is utilized by the testers in their testing environment, therefore, it cannot be accessible on the internet, as it is available on the personal server (localhost). There is no path used in this example. However, you can add any address on which you would like to run the JMeter load test. For instance www.google.com OR www.yahoo.com.

 

Step 3: Add Graph Results

Go to ‘Listener’ to select ‘Graph Results’ to get results in visuals.

Add > Thread Group > Graph Results

 

Step 4: Test and Result Interpretation

 

JMeter Graph Results_PetStore

 

In this case, the Throughput is 89.871 per minute, and Deviation is 142 (greater than Throughput). So, the graph clarifies that JPetstore cannot handle load.

 

Example 4 – Load Testing for JMeter Apache

This example is made to load test JMeter Apache (jmeter.apachi.org) using Graph Results for interpretation.

 

Test Plan and Result

 

Step 1: Adding Thread Group

Similar to previous examples, open ‘Test Plan’ and click on ‘Thread Group’.

Test Plan > Add > Threads > Thread Group

Enter these values in Thread Properties:

  • Number of Threads (users) = 100
  • Ramp-UP Period (in seconds) = 100
  • Loop Count = 20

 

Step 2: Adding Elements of JMeter

Now create HTTP Request Default just like it’s shown in the previous examples.

Thread Group > Config Element > HTTP Request Defaults

For this case, testers have used ‘Path’ to create a request (download_jmeter) for the download page. Therefore, enter the request in the Path field.

Add > Sampler > HTTP Request

 

Step 3: Add Graph Results

Hover on ‘Listener’ to select ‘Graph Results’ to get results in visuals.

Add > Thread Group > Graph Results

 

Step 4: Test and Result Interpretation

 

JMeter Graph Results_JMeter Apache

 

In this scenario, the Deviation is 195 and the Throughput is 1,136.719 (greater than deviation). It means the download page can manage 1,136.719 loads (requests/users) per minute, which pretty impressive.

 

Example 5 – Load Testing for E-commerce Website

When it’s about load testing an e-commerce application, you have to prepare yourself for regular, as well, as seasonal sales, such as Black Fridays, as these events attract more customers, which means the number of loads (visitors) is likely to increase. Considering that there’s an e-commerce platform which still under development, you have to execute JMeter load testing by designing unique users.

 

Test Plan and Result

 

Step 1 – Setting Funnel Realistically

For an e-commerce site, usually customers visit the homepage, look for a product, add it to the cart, and checkout. Now for this example, if you closely pay attention to the software, you would find the ‘Throughput Controller’ option, where you have to set the throughput, as well as, ‘Funnel’ option that can be seen under the ‘Thread Group’ drop-down panel on the left side of the interface. These options help defines user ratio. So you must enter the same values in both options.

For this particular example, testers have 100 percent, virtual users, to visit the Homepage, while 90 percent of users search for a specific product. Out of 90, 60 percent are likely to add a product to the cart, and only 35 percent of users are those who will checkout and complete the buying process. As the test is based on assumption, that’s why the throughput and funnel are set to 90 percent.

 

Step 2: Adding Think Time

For realistic results, JMeter allows you to add ‘think time’ that defines the time real users require to select a product. These are informally called pauses and they are necessary to be included in the test case to make sure the results are close to reality.

Do not add a 1 or 2 seconds delay because that would be unrealistic. That’s why for this example, testers have set 750 milliseconds in the ‘Thread Delay Properties’ for the random delay and set the constant delay to 200 milliseconds. All is done using the ‘Uniform Random Timer’ from the control panel.

 

Step 3: Setting Thread Group Parameter

Just like example 1, you have to include the ‘Number of Threads’, ‘Ramp-Up Period’, and ‘Loop Count’ by clicking the ‘Thread Group’ option. Here are the properties for this example:

  • Number of Threads (users): 100
  • Ramp-Up Period (in seconds): 1
  • Loop Count: 50

 

Step 3: Creating Unique Virtual Users

This step is crucial. You have to make a list of users with a unique name, user ID, password, contact details, and all the information that is needed at the time of checkout. Also, you have to add product keywords to the list to allow virtual users to behave like real users. Moreover, make sure the information you will include in the list has existence on the website. If the platform has zero content, JMeter load testing results will make no sense.

 

JMeter_Unique Virtual Users

 

Once you have completed the list, store it as a CSV-file, and then import it in JMeter during load testing.

 

Step 4: Add Graph Results

You have to add ‘Graph Results’ to see the outcomes in a graphical representation. You can follow ‘Step 3’ of Example 1 to add graph results.

 

Step 5: Test and Result Interpretation

After running the test, you are provided with a test report.

 

JMeter Graph Results_Ecommerce

 

The above visual representation reveals that the Throughput is 64.186/minute, whereas, the Deviation is 122 (greater than the throughput). It means the e-commerce website cannot handle 100 users in one minute, and can only tackle fewer load than expected. Therefore, you have to rectify the errors to make sure the website would bypass the load test.

Note: Depending on several factors, such as your CPU power, testing environment, internet speed, etc., JMeter load testing can produce different results. That’s why it is advised to let the professionals handle the test because they have refined resources, which ultimately reveals true outcomes.

 

Pointers

The above JMeter Load Test examples are concluded using two different versions of JMeter, so don’t panic if you find distinct terminologies in your installed version.  All the above results are interpreted through ‘Graph Results’. Nevertheless, there are other ‘Listeners’ you can use to depict outcomes, such as:

  • Aggregate Report
  • Aggregate Graph
  • View Results in Table
  • View Results as Tree
  • Generate Summary Results

 

Conclusion: 5 JMeter Load Testing Examples

JMeter is a tool used for load testing web applications to know the number of concurrent users they can handle in real-time. The testing is applied to five different programs including Google and Yahoo to identify the load-bearing capacity. Moreover, the results for each example are interpreted using the ‘Graph Results’ listener.  Nevertheless, it’s a complicated process that typically demands professional supervision to assure correct outcomes, which later help in rectifying bottlenecks in the applications. That’s why LoadView is a trusted load testing platform that can ensure reliable results and doesn’t require a massive investment in hardware, time, and effort.

Try the LoadView free trial today.  If you have any questions, you can contact our engineers to answer your queries, and resolve all your load testing problems 24/7.