Wednesday, September 12, 2012

JMeter - Distributed testing using JMeter


   
        This post will help you to configure JMeter servers across various machines. Before we dive into the step-by-step instructions, it's a good idea to define the terms and make sure the definition is clear.


Master – the system running Jmeter GUI, which controls the test.
Slave –  the system running jmeter-server, which takes commands from the GUI and send requests to
the target system(s).
Target – the webserver we plan to stress test.

There will be 1 Master JMeter and Multiple Salves with JMeter Server running on them. Below image will give you some picture -

Copy all JMeter folders to desired slave machines. As part installation of JMeter create environment variables for JMETER_HOME and JMETER_BIN in all the slave machines (even on Master machine).

Step-by-Step

Prerequisites - 

  1. The firewalls on the systems are turned off.
  2. Environment variables are defined for JMeter (JMETER_HOME, JMETER_BIN)
  3. All the machines should be on same subnet. 
  4. Use same version of JMeter to avoid unanticipated errors/issues.

On Slave Machine:

  1. Go to jmeter/bin directory and execute jmeter-server.bat (jmeter-server on unix). If there is any error during server start up check for environment variables related to JMETER, check if the error is related to RMI and check if multiple JRE versions are installed, then do the modifications mentioned from step 2 to 4. else if there is no error during server start up it will be like below screenshot (ignore steps from 2 to 4)-

  2. Open jmeter-server.bat in a text editor
  3. go to line 44 and find “:setCP”
  4. edit “START rmiregistry” to the full path. Example: “START C:\\jre\bin\rmiregistry”

Verification of server on slave machine - 

To check whether server is started successfully or not on slave machine, check below line in jmeter-server.log - (you will know more details from the log )


jmeter.engine.RemoteJMeterEngineImpl: Starting backing engine on

If you do not see this message, it means jmeter-server did not start correctly. (may be due to some firewall blocking RMI Traffic (it can be windows firewall or antivirus firewall)  )


On Master Machine - 

  1. On master system acting as the console, go to jmeter/bin directory open jmeter.properties in a text editor.
  2. edit the line “remote_hosts=127.0.0.1”
  3. add the slave IP addresses. For example, if I have jmeter server running on 10.19.129.38, 39, 40, 41, and 42, the entry would like like this: remote_hosts= 10.19.129.38, 10.19.129.39, 10.19.129.40, 10.19.129.41, 10.19.129.42
  4. Start jmeter.bat to open JMeter master GUI.
  5. Open the test plan you want to use.
  6. Start threads on client machine as mentioned in below screenshot -


To start on all remote slaves (when you have more than one slave), you can select Remote Start All option. Master JMeter will gather results from slaves and display the results using Listeners that are included in the test.

One of the major drawback which I've observed in practice is if you have any config elements which reads data from files, for example CSV Data Config (reading data from CSV), such files will not be sent to Slave machine during running the test. If you have such config elements and you run the test, the test will fail. So such files needs to copied to appropriate folders on Slave Machines. When compared to Load Runner (LR), in LR Controller this will be done automatically.