Consider there is an e-commerce site, it is quite common that there would be highe in certain days like big billion days for example. At situations like this, one needs to load test the application with large number of concurrent users. If we are running the tests locally using Apache JMeter, there would be certain limitations in the number of users we can stimulate independent of the system resources one possess. (CPU, Memory, disk and Network)
The solution to simulate high number of users and test the application with that load is to execute the test in distributed mode. When one talks about distributing load in JMeter, they refer to Master-slave architecture where JMeter users Java RMI(Remote Method Invocation) to interact with objects in a distributed network. The below image depicts the master slave architecture.
The distributed mode of testing is a type of testing where in multiple system will be used to perform stress testing.
To start with detailed steps on how to configure the Master-Slave configuration, let’s have basic understanding on terms below:
Master: system running JMeter GUI, controls each slave
Slave: System running JMeter server, receives commands from master and send request to system or application under test
Target: web or application server under test, gets requests from slave machines
Now that we have understood the terminologies, let’s have a look at the prerequisites to be done before starting with testing in distributed mode:
- The firewalls on the system’s should be turned off
- Ensure all the clients are on the same subnet
- Make sure JMeter has access to the server
- The version of JMeter should be same on all systems. This is to avoid any unanticipated issues/errors
- Server should be in same subnet, if 192.x.x.x or 10.x.x.x servers are used, else there shouldn’t be any problem
- Set JMeter/bin folder path as JMETER_HOME environment variable and jdk1.x.x/bin folder path to PATH environment variable
Once systems are ready with above prerequisites, we cab start with set-up for remote testing. In this distributed mode of testing one master controller initiates test on multiple slave systems.
Steps to be followed on Slave System:
- On slave system, go to jmeter/bin path and execute jmeter-server.bat on windows, jmeter-server on UNIX. Dos window would appear with “jre\(version)\bin\rmiregistry.exe”.
- Open jmeter-server.bat in notepad++ or any text editor
- Search for “:setCP” in line 44
- Edit “START rmiregistry” to full path. For example: C:\<JAVA_HOME>\jre\bin\rmiregistry
Steps to be followed on Master System:
- Go to jmeter/bin path from windows explorer
- Open Jmeter.properties in notepad++ or any text editor
- Edit the line of “remote_hosts=127.0.0.1”
- Add the ip address of slave machines, for example if the JMeter server is running on 192.168.0.5, 6, 7 and 8 then the entry would be like below:
remote_hosts=192.168.0.5, 192.168.0.6, 192.168.0.7, 192.168.0.8
- Launch JMeter on master machine
- Open the test plan which needs to be executed
Starting with the test:
Before starting with test, one needs to check if the slave systems are working as expected. To do that open jmerer.log in notepad. The following should be visible in the log file.
Jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine
Starting test on single client machine:
Click on Run->Remote Start->Select the IP address of machine where we would want to start the test
Starting test on all client machines:
Click on Run->Remote start all or use the shortcut Ctrl-Z
Below is an example of a sample scenario where we can search and view products on an e-commerce website:
As we can see, view results tree Listener has been added to validate if the test was executed as expected or not. When one runs a test remotely, one can locally see the results on view results tree Listener, but in slave systems one can only observe the start and end time of the test.
Running in Slave Machine:
In the backend, each slave system will be executing the load test with conditions that were set in the master system. Using this distributed mode one can achieve higher number of concurrent users and thereby higher load will be generated on the target server.