ColdFusion Muse

Jmeter Part 2: Distributed Testing

In my last post I detailed using Jmeter to set up a simple Web Application test. Jmeter can bring a lot of users to the table with just a single workstation and you can affect some real pressure on your system. But there are times when the resources of the server simply exceed the amount of traffic you send its way. For example:

  • The site is heavily cached or pure HTML and can handle bucket loads of traffic.
  • The server is a huge horse with tons of RAM, fast disks and teamed NICs.
  • You are testing a cluster or load balancer - multiple servers working together for high capacity.
The idea behind distributed testing is to use multiple workstations with a single test plan. Jmeter makes this extremely easy (surprisingly easy considering how difficult it is with other testing products). Here are the details.

Jmeter Server: Step 1 - start 'er up

You will still be using the Jmeter GUI just like in my previous post, but in this case it's going to act more like a Field General manipulating his privates. Or perhaps I should say directing his staff. Anyway, the GUI takes your test plan and farms it out to N number of Jmeter servers listening on various IP addresses. That sounds complicated but it's actually pretty easy. Remember our Jmeter .bat files in the "BIN" directory of our Jmeter install? There's one in there called "Jmeter-server.bat". To start a Jmeter server all you need to do is start that batch file on each workstation or client you intend to use and Viola! your Jmeter server is running.

Jmeter Server: Step 2 - configure the properties file.

Next, gather the IPs of the workstations running Jmeter server and add them to your jmeter.properties file (also found in the BIN directory). Look for the "remote_hosts" property and add your IP addresses as a comma separated list like so:

remote_hosts=127.0.0.1,10.2.18.1,10.2.18.42
Notice I added the 127.0.0.1 address as well. This is because my "master" workstation where I configured my test plan is also going to be running a server and I want to connect to it as well.

Jmeter Server: Step 3 - Remote Test Start

Finally, restart your GUI to pick up the IP addresses. Make sure the server is running on all the workstations that are specified (by IP) in the list. To see the list go to Run menu and hover over "Remote Start" - you should see the list of remote hosts you configured in step 2.



To start your test using all servers simply select "remote start all" and the GUI will send the test plan to all servers simultaneously, multiplying your test by the number of workstations you have configured. If you happen to be watching the command line of your "jmeter-server.bat" command, you will see information in the standard console output regarding the starting and stopping of the test.



The GUI (the master workstation) collects all the data from all of the servers and aggregates it for you automatically.

Gotchas

As you might expect there are a couple of nuances to this process:

  • Remember that if you plan on using a workstation as both a client and a server, you will need to run the GUI and the Jmeter server.
  • This is a network application that listens on a port so you may have to configure your workstation's firewall or network policy to allow it.
  • All the workstations running the server must be on the same subnet. In other words, running server on 10.1.1.2/255.255.255.0 and another on 10.1.2.3/255.255.255.0 will not work. Under the hood the process is using some special network packet magic that does not make it through routers. The exception is the 127.0.0.1 IP address which can differ from the others in the group (because to the GUI the 127.0.0.1 traffic never actually leaves the stack).

Tomorrow I will share a script by CF Guru Wil Genovese that can use Jmeter to crawl your site and test each page and link. It uses some advanced Jmeter hocus pocus like regular expressions and looping - pretty nifty stuff.

Related Blog Entries

Comments
Larry C. Lyons's Gravatar The one time I tried distributed testing using the jMeter server I brought down the entire server. Done wrong the jMeter server can act as a controller for a DDOS.
# Posted By Larry C. Lyons | 7/26/11 3:08 PM
Mark Kruger's Gravatar @Larry,

Yeah... if you are stress testing that's exectly what you are going for - to find the peak capacity of a system. And Jmeter can do it with 2-4 workstations pretty easily unless you are testing a huge LB cluster.
# Posted By Mark Kruger | 7/26/11 4:46 PM
Dave's Gravatar Good post. Better than the description in the JMeter documenation.
# Posted By Dave | 9/4/11 7:33 PM



Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.