How To Execute Distributed Testing in JMeter?

Distributed testing is type of performance testing where we simulate a large number of users accessing an application or website from different machines. It usually involves running the same test plan on all the machines.

Why do we need distributed testing?

What will you do if you need to simulate a large number of users in JMeter? Using a single machine is not practical in such scenarios because one machine will not have the computing power required to process all the requests. In this case, you have to distribute the tests on different machine to share the load. This is what we do in distributed testing.

In all previous topics, we performed the testing on a local computer. In distributed testing, each slave machine acts as a node, to perform the same test.

The below diagram shows the deployment of machines in distributed testing:JMeter_Distributed_Testing_Performance_Load_Tutorial

Terms used in distributed testing

  • Master: A master node works as the controller that initiates and controls the test execution
  • Slave: Test nodes work as a slave, they receive the command from the master and perform a test
  • Target: Your website or application that is being load tested

JMeter_Distributed_Testing_Tutorial_DiagramDistributed testing distributes the test load across the test machines. You can solve the problem of limited computing resources with distributed testing. Moreover, this model can scale by adding or removing test nodes/slaves.

In its current version, JMeter uses RMI to connect and interact with remote machines.

Checklist for Distributed Testing

  • Since JMeter will send and receive data from other systems, you will need to turn off the firewalls on all machines or else it may block the incoming / outgoing traffic. (Experts may be able to open specific ports required by RMI and will not need to disable the firewall completely.)
  • Ensure that all the machines are on same subnet so that they recognize / reach each other. (This is not mandatory but is the easiest configuration option. RMI can communicate across subnets as well but will need a proxy.)
  • Ensure that all machines have the same version of JMeter.
  • It is preferred to have the same version of Java installed on all machines to avoid any issues.
  • You do not need to copy the Test Plan to each slave machine. JMeter automatically runs the Test Plan selected in the Master, on the slave machines.
  • Any files that the test depends on for test data should be placed in appropriate directories on each slave since these will not be transmitted from the master.

Practical hands on exercise on Distributed Testing in JMeter

It is time to learn how to perform distributed testing with JMeter. In this exercise, we will assume that you have two machines (since most people may not have access to many machines). One will act as the master and the other will be the slave node.

The steps will be the same even if you have multiple machines.

The steps required to perform distributed testing are shown below:JMeter_Distributed_Testing_Tutorial_Steps

Step 1. Start slave machine(s) in server mode

  • Open the command prompt in the slave machine and change your directory to the bin directory of JMeter.
  • Start JMeter in server mode. JMeter can be started in server mode using the command jmeter – server.bat
  • Assuming that the IP your slave machine is 192.168.191.2, you will see the following output in the console window.JMeter_Distributed_Testing_Tutorial_Step1
  • If you have more than one slave machine, you can repeat the above steps on each slave, to start JMeter in server mode on each of them.

Step 2. Configure the master machine

  • On the master machine, go to the bin directory of JMeter (\apache-jmeter-2.13\bin)
  • In order to configure the test, edit the file jmeter.properties in \apache-jmeter-2.13\bin.
  • Find the line with property: remote_hosts=127.0.0.1
  • Edit this line to replace the existing value with the IP address of the slave machine. Assuming that the IP address of your slave machine is 192.168.191.2, the property will now be: remote_hosts=192.168.191.2 as shown below.JMeter_Distributed_Testing_Tutorial_Step2
  • RMI will use the port 1099 by default, if you run RMI on a different port, you need to update the port setting for server_port as well.
  • If you have more than one slave, the value of remote_hosts will be: Slave 1 IP,Slave 2 IP,Slave N IP

Step 3. Run the test

  • On master machine, start JMeter in GUI mode, Select Run > Remote Start > Select the IP address of the slave machine.JMeter_Distributed_Testing_Tutorial_Step3
  • This will run the test plan on the selected slave machine.
  • If you have more than one slave machine and you want to start the test simultaneously on all machines, you can choose Remote Start All option in the Run menu.

Limitations of Distributed Testing

  • The server whose performance is being load tested can be overloaded easily if you create too many request through distributed JMeter tests.
  • A slave machine can run up to 600 threads depending on its computing resources and the complexity of the test.

In the next topic you will learn how to record a Test Plan in JMeter with HTTP Test Script Recorder.