• Get Matched

How to Use JMeter to Test Your Web Application

Updated December 5, 2024

Karishma Nimavat

by Karishma Nimavat, SEO Expert and Content Writer, NEX Software at

When developing an application, it’s important to know how it performs under various workloads. Jmeter performance testing and load testing helps determine how responsive and stable an app will be in different scenarios.

 

Updated February 3, 2023

Looking for a Software Development agency?

Compare our list of top Software Development companies near you

Find a provider

Although testing is a key part of app development, many developers underestimate its importance. Skipping the performance testing phase could mean overlooking issues related to security, functionality, quality, accessibility, and performance.

There are several different techniques for testing web apps, but the one we’ll be focusing on is performance testing. This is done to verify server response time and throughput under different load conditions. 

Apache JMeter is a great Java-based resource for companies looking to conduct performance and load testing. 

What is JMeter?
Apache JMeter is an open-source, 100% pure Java application that load-tests functional behavior and measures performance. JMeter simulates a heavy load to test an app’s strength and analyze its overall performance under different load types. 

Functional testing is key for all types of apps, especially ones with plugins and other features that might need debugging. 

JMeter flexibly tests the dynamic and static resources of an application. Now, you might be wondering what these resources are. Dynamic resources include JSP, Servlets, and AJAX, while static resources are Document Object Model (DOM) elements like JavaScript and HTML. 

Looking for a web app development company? Check out our directory page to find the right partner for your upcoming project.

Types of JMeter Performance Testing

JMeter can perform two types of performance testing. Let’s have a look at them:

1. JMeter Load Testing

JMeter simulates users and models expected usage. The users access the web service simultaneously, allowing you to know how many users your app can support. 

Load testing tools can deliver accurate test results for users. 

2. JMeter Stress Testing

Every web service on the planet has a load-bearing capacity which, if exceeded, means that the system won’t perform well. You could say that this is the breaking point for an application. In the testing environment, JMeter applies stress beyond the app’s bearing capacity, thereby determining the maximum load that the server can handle through response data.

The diagram below shows how JMeter models users and simulates a heavy load: 
 

Create a copy of sampler individual users can use to send requests and receive HTTP responses.

Source

As you can see, JMeter models users to calculate an app’s expected usage and load-bearing capacity with performance testing tools.

How to Use JMeter for Performance Testing

  1. Create a thread group
  2. Add thread properties
  3. Add JMeter elements
  4. Run test
  5. Analyze results

Now, to help you understand how to actually do performance testing using JMeter, we’ll be testing Google’s full website and modeling 1,000 users. Let’s look at each step in detail: 

1. Create a Thread Group

First, you must create a thread group.

A thread group is a basic element in a JMeter test plan - these groups of threads can execute the same scenario within a Jmeter script. 

To create a thread group, start with the following: 

Install and launch the JMeter application. Right-click on “Test Plan,” which you will see on the left panel. A test plan is made up of a sequence of test components that determine how the load test will be simulated.

Right click on “Test Plan,” which you will see on the left panel.

Under “Test Plan,” click “Add,” then “Thread (Users)” and finally “Thread Group.”

You've successfully created a thread group. 

 

2. Add Thread Properties

The Thread Group has three key properties that influence the load test. You enter the Thread Properties by navigating to the Thread Group control panel. These properties include:

  1. Number of Threads (or Users): The number of users that you want to model accessing the application simultaneously. Set the value to 100, because we want to model 100 users on the Google website.
  2. Loop Count: The number of times JMeter simulates a user. We will set this to 10.
  3. Ramp-Up Period: The time it takes in seconds for JMeter to model a new user. We’ll set this time to 100 seconds. 

Understanding the difference between Loop Count and Number of Threads is critical, so let’s explain this in detail. Number of Threads are the total number of users that will connect to the web service at once, while Loop Count is the number of times an individual user connects to the web service. 

Check out the diagram below for more clarification:

Number of Threads are the total number of users that will connect to the web service at once, while Loop Count is the number of times an individual user connects to the web service.In the example above, JMeter creates 100 concurrent users. These users will be accessing the web service all at once. We have defined the Loop Count as 10, so that means every user made by JMeter would be connecting to the server 10 times.

3. Add JMeter Elements 

You’ve created a Thread and added Thread Properties. Now, it’s time to add JMeter elements that are Java-based: 

  • HTTP Request Default: Attach the HTTP Request Defaults element to your thread.

Right click on “Thread Group” and click “Add,” “Config Element,” and “HTTP Request Defaults.” Then, enter the site or server name that you want to access under “Server Name or IP.”

Since we want to access www.google.com, we will be writing this in the server name:

This graphic shows what you’d enter into “Server Name of IP” if you were testing Google.

This graphic shows what you’d enter into “Server Name of IP” if you were testing Google. 

  • HTTP Request Sampler: Add the HTTP Request Sampler to the Thread Group. Right click on “Thread Group,” then click “Add,” “Sampler,” and “HTTP Request.” 

You can see these steps in the screenshot below:

Upon selecting “HTTP Request,” fill in the URL request you want to send to the server.

Upon selecting “HTTP Request,” fill in the URL request you want to send to the server. In our example case, the server is www.google.com. 

Now, fill in the item that you want each Thread, or user, to request. Fill in the “Path” field with parameters, which we will set as “calendar.” The final query would be www.google.com/calendar.  

The red box is where you’d enter “calendar”

If you don’t enter a parameter in the Path field, then the user will only request www.google.com. You don’t need to specify Google here, because it was already specified in the HTTP Request Defaults item — so just enter “calendar.”

  • Output Results: JMeter uses listeners to output the results of a load test. Right click “Thread Group” and click “Add,” “Listener,” and “Graph Results.”

For more clarity, see below:

Right-click

JMeter is a very powerful tool that can show the results in graph format

JMeter is a very powerful tool that can show the results in graph format - through a view results tree. 

4. Run the Test

With the basic test plan set up, it’s time to run it and see the results. Under “Test Plan” and “Thread Group,” click “View Results in Table,” then “Run” from the main menu. Click “Start,” or the green start arrow below the main menu, to begin the test. 

Click “Start,” or the green start arrow below the main menu, to begin the test.

As the test is run, the results appear in the table in real-time. In our example case, 100 users would be accessing the Google server simultaneously, with every user connecting to the server 10 times. 

5. Analyze the Results

Carefully analyze the graph that you got in real time. Here are the two main factors to consider: 

  • Throughput: The measuring capacity of the server, or how much it can handle. Ideally, this number should be infinite, if not very high.

It’s important to note that throughput depends on other factors, such as internet speed, the Google server’s current load, and CPU power. These factors continuously change, meaning you won’t get the same results every time you run the test. 

  • Deviation: The variation from the average. This number should be zero, or very low.

Here is the output graph we’d get using our Google example:

The output report comes in five colors, each of which signifies something different.

As you can see, this output report comes in five colors, each of which signifies something different:

  • Black- the total number of samples sent to the server
  • Blue- the average of the total number of samples sent to the server
  • Red- the standard deviation in real-time output
  • Green- the throughput rate (the number of requests the server handled per minute)
  • Purple: the median (a number which divides the samples into two equal halves)

How would we analyze this graph?

  • The throughput is 867 requests per minute. 
  • This means that the Google server handled 867 requests per minute.
  • Sometimes, the throughput even got 1,000 requests per minute. 

Based on these numbers, we can deduce that Google has very good throughput. 

JMeter is a Helpful Tool for Performance Testing

Performance testing or API testing is a crucial step in determining how your web app will perform under heavy loads. JMeter is a valuable tool for performance testing, as it can discover the maximum number of users that your web app can handle. 

JMeter does both load testing and stress testing; while load testing models expected usage by simulating concurrent users, stress testing determines the maximum load that a web server can handle. The results of these tests will help you reduce bottlenecks and boost performance.

Testing is one of the most critical parts of any software development project. We’ve only touched on JMeter in this article, but there are lots of automated QA software testing solutions and tutorials out there. Consider a development partner to help your business navigate testing nuances to ensure your app provides users with a seamless user experience. 

Need Help Selecting a Development Partner? 

We’ve created a directory of app development firms to help you compare and connect with the right companies. Use client review ratings, services offered, and client focus to create a shortlist of development teams. If you want personalized recommendations, share your project details with us

Additional Resources: 

Related Articles

More

10 Best Static Code Analysis Tools
Technology Adoption Curve: 5 Stages of Adoption
Software Development Checklist: 7 Considerations