Controlling Jmeter Slaves on EC2 from your Local Machine

Pretty cool idea I would say if you can control Jmeter slaves on from your local machine.

Overview

To generate a load of ≥ 6000 RPM, you should have the following distributed Jmeter set up an run it via this configuration. Without having distributed jmeter, tests would be suceptable to coordinated omission and other issues that would render the test invalid or incorrect.

The setup is basically consists of having Jmeter slaves (few nodes) on EC2 instance and a controller on a local machine (or ec2, but then this article is about having it on your local machine ;) and it’s much easier to control from EC2 instance within the same subnet).

Distributed Jmeter on AWS EC2, controlled from Local Machine

Each of the Jmeter slaves is on an ec2 instance running ubuntu (or any other os of your choosing). After setting up 1 machine with a simple script (which you can see below in the “Le Script “ section below) to start the Jmeter Server, it then can be created into a reusable image which then can be used as an ec2 instance template. From the ec2 template, you can duplicate the ec2 instance easily via ec2’s “Launch instance from template” feature.

Why not ECS?

Distributed Jmeter uses Java RMI to work. There are few ports required for the slave/s and the controller to communicate. Using ECS, a custom docker image needs to be built in order specify those ports (the default is randomly selected which is dificult when you want to specify the port mapping in the ECS’s task definition). Currently, no pre-existing images was found that has the ability to configure the ports.

Moreoever, managing the slaves via controller would be easier as the ports would be the same for all instances and the controller would only require to specify the right host (and the same port) in order for the controller to connect with the slaves.

Settings

There are a few configurations / settings that you need to change in order to make it work on both the slaves and the controller.

Slave onfigurations

The following configurations are in jmeter.properties, usually together within the bin folder.

  1. “client.rmi.localport” to something that’s free to use
  2. “server.rmi.localport” also to something that’s free to use
  3. “server.rmi.ssl.disable” to false IF you don’t want to use SSL for the connection between the slaves and controller
  4. “-Djava.rmi.server.hostname=” when starting jmeter-server (your slave). But this is taken care by the script.

Controller Configuration

  1. All the public DNSes need to be included in your controllers’s jmeter.properties. The property you need to put in is “remote_hosts”. Multiple hosts can be separated by comma ‘,’.
  2. Then, append “-Djava.rmi.server.hostname=” parameter when running jmeter with the value of your machine’s public IP. You can google something along the lines of “my public ip”.

Port Forward / Adding in DMZ

You need to port forward (on your modem) your host (the controller) so that it can be accessable from outside. Or the more convinient way, risky, put your host in the DMZ configuration. For short test, easier to just put it in the DMZ.

Off couse this can be done if you are at your home. If you want to do this from your office or somewhere where you have no control over the gateway router / modem, then you gotta ask the relevant parties to help you.

Security Policy on EC2

Make sure that the ports you configured on the Jmeter slaves are included in the inbound and outbound configuration of the ec2’s security policy.

Le Simple Script

The script involves obtaining the public DNS of the EC2 instance where the Jmeter slave is running. You can use cloud-utils package to get public hostname.

The script looks something like this:

PUBLIC_DNS=$(ec2metadata --public-hostname)(exec bin/jmeter-server -Djava.rmi.server.hostname=$PUBLIC_DNS)

You run this on each of the new instance you deployed. OR, you can run this script as service on startup. If you do so, you can include this in the image for later deployments.

Scaling Up

To increase the number of slave node you can do the following:

  1. Launch another instance from template
  2. Run the jmeter slave via configured script above (or if you make it into service and run on startup, you can skip this step)
  3. Add the public DNS on your Jmeter controller.
  4. Start Jmeter on your local machine.
  5. Test away.

Conclusion (The Steps, Concisely)

In summary, to make it work you need to:

  1. Ensure that the jmeter slave hosts IP is the public DNS of the EC2 instance.
  2. Ensure EC2 instance policy is correctly set (which port to open) and reachable from outside
  3. Ensure that the IP of the controller is the public IP of your machine (you can google my IP). Assign by your ISP.
  4. Ensure your controller machine is port forwarded or put in DMZ (riskier but convinient)

Then, you can begin testing.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maziz

Maziz

7 Followers

Someone who bricked a motherboard after flashing the wrong rom because of trying to OC an intel celeron from 400mhz to beyond 600mhz in 3rd grade.