Apache JMeter, or JMeter, is an open-source software for load and stress testing. It analyzes and measures service performance, including website performance metrics. This is a useful tool as it allows us to track an application's performance after deployment, providing us with information that we can use to improve our service further.
Before we can start installing JMeter, we need to make sure our machine has Java installed. If we use Windows as our operating system, head to the official Java website or use the following code in our terminal for Linux machines.
java --version // checks if java is installedsudo apt install default-jdk // installs the latest Java version
Now we can start to download and install JMeter.
To begin, we will head to the Apache JMeter download page. From here, we download the latest binaries.
After the download is complete, we will extract the file. For Windows users, head into the "bin" folder and open the "JMeter.bat" file to start the process. For Linux users, use the "./jmeter" command in the terminal inside the bin directory. This will start the JMeter GUI, which is the same for everyone, regardless of your machine.
As our Apache JMeter GUI has started, we can now create different load testing conditions. However, before we proceed, we need to learn about some new terms within JMeter.
Thread Group: This collection of threads represents one user per thread. We can modify the number of thread groups to simulate multiple users requesting the service.
Samplers: The controller lets us set which type of request we need to send to our service. It provides multiple options, including
Listeners: These show the results of the requests. This can be in a graphical, tabular, tree, or log format.
Configuration: This sets up the default configurations and variables the samplers use. Examples include CSV management, login configuration element, and more.
Now we have all the tools ready to start our testing.
We begin by using the test plan provided (we can also change its name if need be). To start our process, we right click on the plan to open the popup menu as shown below.
Now we will add our thread group. For that, we click the "Threads (Users)" option and then click "Thread Group". We can rename this and modify its setting. Some main properties of it include "number of threads," which allows us to set the number of users to simulate, the "ramp-up period," which indicates the time taken for all threads to deploy. And the "loop count," which tells us how many times the entire process will run.
We have created our threads, but now we must let them know which type of request to send. Therefore, we will now add a sampler. In our example, we will use the HTTP request sampler.
The following image shows the configuration details of the HTTP request, but we can use multiple types of samplers for different jobs.
After we have added our sampler, we need to see the output values. For this, we use a listener, as shown below. We will use the "view results in table" output format in our example.
We are almost finished. Before we can run this, we need to save this ".jmx" file. We can do this by clicking the save icon or navigating to the save option in the files tab.
Now it is time to run our plan. We do that by clicking the run (green arrow) icon or the run tab.
JMeter allows users to easily test their services after deployment, allowing better monitoring and maintenance. Moreover, the simple UI allows users to create multiple tests from any number of simulated users. This allows for complete coverage of all samplers and, in essence, mimics real-world usage patterns.
Free Resources