Dang Luong

Using JMeter Part II – Multi-Client Testing

Blog Post created by Dang Luong on Jan 16, 2015

This is a follow-up to the blog Using JMeter to Benchmark HCP HS3. That blog was an introduction to JMeter. It demonstrated how to set up JMeter to run on one client. Now, we will look at how to configure it to run across multiple clients.

 

This is a common requirement for performance testing. Typically, a single client is unable to saturate the device being tested, so multiple clients are required. The tester could individually initiate the same test on each client. But of course, this is inefficient. A good benchmark tool, such as JMeter, would have the ability to coordinate test runs across multiple clients and aggregate the results for the user.

 

Prerequisites

These are the prerequisites necessary for JMeter to run multi-client tests.

 

  • Same version of JMeter on all clients. JMeter’s website says this is a recommendation only but I have had problems starting test runs with different versions across the clients.
  • JMeter installed on the same path on all clients
  • Recommend same version of Java on all clients
  • Sample data files exist on all clients

 

Define Remote Hosts

In my test bed, I have installed JMeter on four servers. One of them will be used as the Master and the remaining three servers will be the clients. The Master server is the one that coordinates the starting and stopping of test runs among the clients as well as aggregates test results. I have arbitrarily picked the server with the lowest IP address to be the Master.

 

  1. Open the file “C:\apache-jmeter-x.xx\bin\jmeter.properties”.
  2. Locate the line “remote_hosts=127.0.0.1”.
  3. Append the IP addresses of the clients to the line. Separate values with a comma.
  4. Here is my example after the change: remote_hosts=127.0.0.1,172.17.173.214,172.17.173.215,172.17.173.216.

 

Define Distinct Counters

With the single client setup, my JMeter Test Plan had a counter that ranged from 0 to 100,000. Essentially this meant that the client would operate (for example: write, read, delete) on data files with names within that range. This method does not work in a multi-client test. Take a delete operation for example: multiple clients meant to delete the same file but only the one client would be able to complete the operation successfully.

 

The solution is to specify a distinct starting counter on each client. For example, give the first client the starting value of 1. Second client would start with 100,001. Third client would start with 200,001. This would allow each client to work with a maximum of 100,000 unique files. To implement this system, perform the following steps on all JMeter servers.

 

  1. Open the file “C:\apache-jmeter-x.xx\bin\system.properties”.
  2. Add this entry to the end of the file: clientCounterStart=1. Change the value to the appropriate starting number for each client.

 

Next, we have to update the Test Plan.

 

  1. On the Master server, open JMeter. Load the Test Plan that we created during the previous blog.
  2. On the left explorer panel, select MyTestPlan.
  3. [Optional Step] On the right panel, there is a list of user defined variables. One of them is a counter variable called “client1CounterStart”. You can delete it because we will be using a different counter.
  4. On the left explorer panel, expand the first thread group. In my Test Plan, it is called HCP_SmallFile_Write.
  5. Select the Counter object.
    1.png  
  6. Change the value of the parameter Start to: ${__property(clientCounterStart)}. This tells JMeter to use a counter variable that is defined in the system.properties on each client.
  7. Update the Counter object of the remaining thread groups in the same manner.

Start & Stop JMeter Listener

Prior to starting a multi-client test, we have to run jmeter-server.bat on all JMeter servers, including the Master server. This starts JMeter in a listening mode that allows it to be coordinated remotely from another JMeter instance.

 

If you have a handful of clients, you could log into each one and manually start the program. Do this by running C:\apache-jmeter-x.xx\bin\jmeter-server.bat.

 

If there are lots of clients, I recommend using a tool to remotely start (and stop) jmeter-server from the Master server. Microsoft’s PSTools can do this (http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx). Download the software to the Master server and extract the content to C:\PSTools.

 

Create a batch file to start JMeter on all clients. Use the example below.
2.png  

Create a batch file to stop JMeter on all clients. Use the example below. Note that this command will stop all Java processes so be careful if there are other Java applications running on these clients.
3.png  

Run Multi-Client Tests

Now we are ready to run our first multi-client test.

  1. First, start the JMeter listener on all test servers, including the Master server.
  2. Open JMeter GUI on the Master server. Open your Test Plan.
  3. Select Run from the menu bar > Remote Start. It should list all the remote hosts that we defined earlier.
    4.png  
  4. The option that we want is Remote Start All which will start the test on all clients simultaneously. Give it a try.
  5. Under the Summary Report object, you will find the aggregated results for all clients and thread groups.

 

Enjoy! Comments are welcomed. Feel free to contact me if assistance is required.

Outcomes