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.
Testing is an important part of checking our service's limitations and capabilities. However, sometimes one client cannot load the service under enough stress to reach its maximum limit. This is where distributed testing occurs, specifically, the master-slave mechanism. The boss-worker, or master-slave mechanism, is a method in which one entity controls the metrics, i.e., speed, utilization, etc. In contrast, multiple entities follow the commands of the main entity. This allows easy control from the main entity of multiple entities, which enables an organized control of the process and efficient management.
JMeter also uses this master-slave mechanism in its load testing. It creates multiple slave systems that can be emulated to act as multiple machines. This puts an extra load on the service at hand and enables the user to test it to its limits. The following diagram gives an overview of how this relationship can be visualized.
Now that we understand how the distributed testing model works, we will switch to implementing it.
Note: If you have not set up your JMeter, follow this answer to first set it up and then continue with this Answer.
We can begin our implementation by knowing the theory behind our distributed model. However, keeping a few things in mind before proceeding is essential.
All systems (master and slaves) should have the same version of JMeter.
All systems should have the same version of Java.
All systems should be able to connect, i.e., are in the same subnet.
We do not need to copy the JMeter script (.jmx) to slave systems.
Finally, if we want to have 100 users using 4 slaves. We will give 25 as our number of users.
Before testing our service, we must set up our master and slave systems. To do that, we will follow the given instructions.
We will go to our JMeter folder and then into its "bin" folder. Here we will search for the "jmeter.properties" file and open it.
Once in the properties file, we will search for the "remote_hosts" keyword. We will find a value already assigned to it. This is our master system initialized to our machine. We will add another line denoting the slaves with their respective IPs. For this example, we will add our machine as the IP to the slave category. We can also add multiple slaves by separating their IPs with a comma. Finally, save and close the file.
After this, we need to create its "rmi-key". Open the "create-rmi-key-store.sh" file for Linux and Mac or "create-rmi-key-store.bat" for Windows. When we run the file, we will get a few questions. Fill in the answers as required. Remember to set the first and last name question as "rmi". An example solution is given below.
Now we will start our JMeter GUI and create a simple plan. For this, we can either import a template or create one from scratch. We will use the one in the setup answer above for this example. With this, our master system is ready and working.
On to the slave systems. We will head to their respective "bin" folders to set those up. We will open the "jmeter-server.sh" file for Linux and Mac or "jmeter-server.bat" for Windows there.
After starting the slave system's servers, we will head to our master system and send a remote start request to the slave systems. Follow the steps in the slideshow below.
JMeter distributed testing allows testing from one to a multitude of low-end machines, allowing for better load balancing on the user's side while also increasing the maximum load on the service in question. Although it may require more resources, it provides an opportunity that can detect shortcomings in our service. Therefore, identifying these shortcomings before they cause problems is a major positive for large services and henceforth provides a reason for JMeter's popularity.
Note: To learn more about distributed testing, check the official documentation.
Free Resources