Running distributed JMeter test

Reasoning

For running a significant Load Test (with hundreds or even thousands of concurrents) it might be necessary to utilise capacities of more than one machine. This instruction explains how to run a distributed load test where local machine operates JMeter controlling GUI only and all the load testing is done by remote JMeter servers (kind of slave nodes).

The overall process diagram looks like this:

Installation

    1. Download the most recent binary from http://jmeter.apache.org/download_jmeter.cgi to all your machines: your client (e.g. your local computer and your servers which will do the load test itself)
    2. cd to jmeter root and run:
  • sudo chmod -R +x bin/

* Note that you need java running on all the machines for JMeter to work. JMeter site also suggests running the same version of Java and JMeter on all the systems. They say that mixing versions may not work correctly.

Variant 1 (via config)

Client configuration

On the client (e.g. controlling jMeter instance on your machine) edit <jmeter root>/bin/jmeter.properties and add:

remote_hosts=127.0.0.1:55501,127.0.0.1:55502

# should be all localhost records and port should match the one used 

# for “server_port” on remote servers

 

client.rmi.localport=55512

# if you don‘t specify the port it’s randomly assigned which makes it slightly more 

# difficult to know which port to forward with -R

 

mode=Batch

# Optional change.

# Batch mode returns samples in batches. The default mode is StrippedBatch which 

# returns samples in batch mode (every 100 samples or every minute by default). 

# StrippedBatch also strips response data from SampleResult while Batch doesn’t

 

num_sample_threshold=250

# Optional change.

# means every 250 samples or every minute. It is 100 by default

Server configuration

On the server edit bin/jmeter.properties and add:

# Server 1

server_port=55501

server.rmi.localport=55511

 

# Server 2

server_port=55502

server.rmi.localport=55522

 

# Server N

server_port=<…>

server.rmi.localport=<…>

Note, that you only specify exact server_port to be consistent and sure about what to use in SSH tunnel afterwards. If you don’t specify it you’ll have port 1099 by default.

That works fine on remote servers but should be changed for local as you can not specify identical ports for remote_hosts values (e.g. this would be incorrect: remote_hosts=127.0.0.1:1099,127.0.0.1:1099)

Note, that you set server.rmi.localport to some exact value just in order to know it beforehand. jMeter tells you this port number anyway when you start the server:

$ ~/apache-jmeter-2.13# bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1

Created remote object: UnicastServerRef [liveRef: [endpoint:[127.0.0.1:55511](local),objID:[…

Note the endpoint:[127.0.0.1:55511] which contains the port number.

Starting jMeter instances

# Issue on Server 1

bash bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1

 

# Issue on Server 2

bash bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1

 

# Issue on local controlling jMeter server

bash bin/jmeter.sh -Djava.rmi.server.hostname=127.0.0.1

# note that can here we start JMeter GUI which is also fine for distributed LT

Launching SSH tunnels

Run locally to create ssh tunnels (different terminals):

# Terminal 1

ssh -vN -L 55501:127.0.0.1:55501 -L 55511:127.0.0.1:55511 -R 55512:127.0.0.1:55512 V338

 

# Terminal 2

ssh -vN -L 55502:127.0.0.1:55502 -L 55522:127.0.0.1:55522 -R 55512:127.0.0.1:55512 V364

where

      1. both -L parts are required for remote jMeter servers to operate normally
      2. -R part is only required to get the data back from remote servers (e.g. to see it in local GUI). Without this part LT is still running on server, but there’s no “feedback”

Variant 2 (via CLI params only)

Servers configuration and launch

On all the servers (note, on servers only, not on your controlling JMeter client) cd to jmeter root and run:

$ bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 -Jserver_port=[port1] -Jserver.rmi.localport=[port2]

Note that you can randomly choose ports but be sure they can be used.

E.g. we could issue these commands on servers:

# Server 1

$ bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 -Jserver_port=10101 -Jserver.rmi.localport=10102

 

# Server 2

$ bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 -Jserver_port=20101 -Jserver.rmi.localport=20102

 

# Server N (be aware that there’s “N” in port number. Put a number instead)

$ bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 -Jserver_port=N0101 -Jserver.rmi.localport=N0102

Client configuration and launch

Launch your jMeter controlling instance (e.g. on your local computer).

Important:

      • make sure you specify all the jmeter servers/ports separated by comma
      • parameter “client.rmi.localport” is a randomly chosen port (possible to be used)

$ bin/jmeter.sh -Djava.rmi.server.hostname=127.0.0.1 \

    -Jremote_hosts=“127.0.0.1:[server_port on server #1],127.0.0.1:[server_port on server #2]” \

    -Jclient.rmi.localport=[port]

In our example (for server #1 and server #2) that would be:

$ bin/jmeter.sh -Djava.rmi.server.hostname=127.0.0.1 \

    -Jremote_hosts=“127.0.0.1:10101,127.0.0.1:20101” \

    -Jclient.rmi.localport=10100

Starting SSH tunnels

Finally, start ssh tunnels with corresponding servers.

For each server issue:

ssh -vN \

    -L [server_port]:127.0.0.1:[server_port] \

    -L [server.rmi.localport]:127.0.0.1:[server.rmi.localport] \

    -R [client.rmi.localport]:127.0.0.1:[client.rmi.localport] \

    user@server

In our example we’re issuing:

# Terminal 1

ssh -vN -L 10101:127.0.0.1:10101 -L 10102:127.0.0.1:10102 -R 10100:127.0.0.1:10100 V364

 

# Terminal 2

ssh -vN -L 20101:127.0.0.1:20101 -L 20102:127.0.0.1:20102 -R 10100:127.0.0.1:10100 V338

Start testing

In jMeter GUI click on “Run -> Remote start all” to start testing from remote servers.

Resources

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s