Saturday, April 30, 2011

How to use jMeter in server mode over an SSH tunnel - Part 2 - Mutliple server instances

This article describes how to run one client JMeter instance with MULTIPLE server instances with inter-JMeter communication tunneled over SSH.

Please read the previous part first (How to use jMeter in server mode over an SSH tunnel).

1) SSH TUNNELS (created from the client machine)
We assume that:
- we have a client machine and a server machine
- client JMeter instance runs on the client machine
- both server JMeter instances run on the server machine.
- we have two server JMeter instances

Create following tunnels:
(tunnels to instance 1)
Local port: 55501 -> 127.0.0.1:55501
Local port: 55511 -> 127.0.0.1:55511
(tunnels to instance 2)
Local port: 55502 -> 127.0.0.1:55502
Local port: 55513 -> 127.0.0.1:55513
(mutual tunnel for callback)
Remote port: 55512 -> 127.0.0.1:55512

2) CLIENT CONFIG
remote_hosts=127.0.0.1:55501,127.0.0.1:55502
client.rmi.callbackport=55512

3) PREPARE JMETER SERVER INSTANCES
Create 2 separate JMeter application folders on the server machine, e.g.
jakarta-jmeter-2.3.4-inst1
jakarta-jmeter-2.3.4-inst2
and put the patched JMeter application into each of them.

They will have different configurations in jmeter.properties. (The same result could be also achieved by having only one application instance and by specifying the different configuration parameters in the start up script on command line.)

Prepare start-up scripts:
(start-jmeter-server-inst1.sh)
#!/bin/sh
./jakarta-jmeter-2.3.4-inst1/bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 2>&1 >inst1.log &

(start-jmeter-server-inst2.sh)
#!/bin/sh
./jakarta-jmeter-2.3.4-inst2/bin/jmeter-server -Djava.rmi.server.hostname=127.0.0.1 2>&1 >inst2.log &

3) SERVER CONFIG - INSTANCE 1
(jakarta-jmeter-2.3.4-inst1/bin/jmeter.properties)
server_port=55501
server.rmi.localport=55511
server.rmi.localhostname=127.0.0.1

4) SERVER CONFIG - INSTANCE 2
(jakarta-jmeter-2.3.4-inst2/bin/jmeter.properties)
server_port=55502
server.rmi.localport=55513
server.rmi.localhostname=127.0.0.1

5) GO
Open SSH connection from client to server machine
Start client JMeter
Start server JMeters
Remotely run your test
Check inst1.log and inst2.log for logs from the server instances

6) Done!


TROUBLESHOOTING
1) Ports are already in use on server machine
Make sure no previously started JMeter is running in the background.

2) There are no results coming back to client instance
Make sure you patched also the client instance JMeter application.