Distributed JMeter Testing Via SSH

JMeter is an open source application written in Java, developed by the folks from The Apache Software Foundation, which allows one to perform load tests against their webservers.
JMeter allows you to run tests from you workstation against your servers, but you can also setup virtual test servers that would allow you to run a heavier load.
If you run JMeter from your machine, you’ll probably end up consuming tons of cpu and memory, depending on how large your tests are, so, to avoid that, you can seetup your workstation as a JMeter MASTER and any number of virtual machines as JMeter SLAVES, which you will be able to control from your workstation. This setup is called Distributed JMeter Testing and that is what I’ll walk you through in this tutorial.

The first step is to go ahead and download the latest JMeter, keep in mind that it has been advised the same version of JMeter must be installed on your workstation (MASTER) and all your virtual machines (SLAVE). Ok, with that out of the way, from your workstation (I’m assuming Linux here, sorry, I don’t work with Microsoft products nor am planning on doing it anytime soon in this lifetime).

For the purposes of this tutorial, MASTER is your workstation and SLAVE is your virtual server.

MASTER:

1. Download the app and extract it.

cd /opt/
wget http://www.trieuvan.com/apache/jmeter/binaries/apache-jmeter-2.8.tgz
tar xzvf apache-jmeter-2.8.tgz

Now we’ll edit the configuration file /opt/apache-jmeter-2.8/bin/jmeter.properties

First comment out the line below:

vim  /opt/apache-jmeter-2.8/bin/jmeter.properties
#remote_hosts=127.0.0.1

Continue editing the same file and add your virtual servers (SLAVES) instead (for the purpose of this tutorial, we’ll be setting up 3 virtual servers, but you can add as many as you’d like):

remote_hosts=192.168.1.5,192.168.1.6,192.168.1.7
 

Continue editing the same file and add/change/uncomment the lines below:

client.rmi.localport=33000

mode=Asynch
asynch.batch.queue.size=250
 

Now we’ll make some changes to jmeter.sh. Just add the lines below to /opt/apache-jmeter-2.8/bin/jmeter.sh

vim /opt/apache-jmeter-2.8/bin/jmeter.sh

JVM_ARGS="-Djava.rmi.server.hostname=localhost \ 
-Xms512m -Xmx512m \ 
-XX:NewSize=128m -XX:MaxNewSize=128m \ 
-XX:SurvivorRatio=8 \ 
-XX:MaxTenuringThreshold=2 \ 
-Dsun.rmi.dgc.client.gcInterval=600000 \ 
-XX:PermSize=64m -XX:MaxPermSize=64m \ 
-verbose:gc -XX:+PrintTenuringDistribution"

MASTER config is done, all configuration from this point on should be done on your SLAVE servers.

SLAVE

1. Download the app and extract it.

cd /opt/
wget http://www.trieuvan.com/apache/jmeter/binaries/apache-jmeter-2.8.tgz
tar xzvf apache-jmeter-2.8.tgz

1. Now we’ll edit the configuration file /opt/apache-jmeter-2.8/bin/jmeter.properties

vim /opt/apache-jmeter-2.8/bin/jmeter.properties

server.rmi.localport=30000

2. Add the lines below to jmeter-server

vim /opt/apache-jmeter-2.8/bin/jmeter-server

RMI_HOST_DEF=-Djava.rmi.server.hostname=192.168.1.5

Follow the steps above for all other SLAVE servers you might have, in this example, we used 3 of them, so follow the steps above 2 more times and remember to change the ip address in step 2 to match that of your virtual server.

Steps below are to be run from your workstation (MASTER)

Now that the JMeter has been installed on all 3 virtual servers, we need to create a ssh tunnel that’ll allows us to communicate between the MASTER and SLAVES. From your workstation (MASTER) run the following (This needs to be done in separate shells, 1 for each SLAVE and make sure to NOT close the ssh session):

ssh -R 33000:localhost:33000 198.168.1.5
ssh -R 33000:localhost:33000 198.168.1.6
ssh -R 33000:localhost:33000 198.168.1.7

Step below to be run from each SLAVE:

Keep all 3 tunnels open and start JMeter on each SLAVE:

/opt/apache-jmeter-2.8/bin/jmeter-server

Steps below to be run from your workstation (MASTER):

Now go back to your workstation (MASTER) and start Jmeter:

/opt/apache-jmeter-2.8/bin/jmeter.sh 

After JMeter has been started, go to run->Remote Start and you should see your servers listed:

That’s it, you’ve now setup both Jmeter Master and Slaves so you can start load testing your web servers. Thanks for stopping by once again and remember, share with others, after all, code should be free.foscode.com | because code should be free

One thought on “Distributed JMeter Testing Via SSH

  1. Hi,

    Useful article, thanks! After starting load test, it starts only on slaves or on master too? What is the probability of report loss? Also, what do you think about cloud load testing?

    Some minor change: sed ‘s/seetup/setup/g’ :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>