Setup JMeter 3-Node Cluster on AWS EC2

Shrihari Haridas
3 min readFeb 19, 2023

--

  1. Login to Your AWS Account
  2. Launch EC2 Instance with following configuration
1. Choose Ubuntu OS
2. Choose t2.medium Instance type
3. Open port 1099, 50000, 22, 80, 60000, 2377
4. Launch 4 Instance i.e. 1-Master, 3-Node/Slave
Launch 4 Instance with above configuration

3. Login your all 4 Instance and update all

sudo apt-get update

4. Install Docker on all 4 Instance

5. Next, install a few prerequisite packages which let apt use packages over HTTPS

sudo apt install apt-transport-https ca-certificates curl software-properties-common

6. Then add the GPG key for the official Docker repository to your system

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

7. Add the Docker repository to APT sources

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

8. This will also update our package database with the Docker packages from the newly added repo.

Make sure you are about to install from the Docker repo instead of the default Ubuntu repo

apt-cache policy docker-ce

9. Finally, install Docker

sudo apt install docker-ce

10. Check docker status

sudo systemctl status docker
Installed Docker on all 4 Instance

11. Now Install Docker-Compose only on Master Instance

# curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

# chmod +x /usr/local/bin/docker-compose

12. Setting Up Docker Swarm on Master Node

docker swarm init --listen-addr <master-private-ip>:2377 --advertise-addr <master-private-ip>:2377
Setting-Up docker swarm on master node

13. Now setup docker-swarm on slave node, so copy above command when you will configure docker swarm on master as per image

docker swarm join --token <TOKEN> master-private-ip  <-- Run this command on all the slave nodes
Join all 3 slave node as a worker node

14. Login again master and pull following repository

# git clone https://github.com/ajeetraina/jmeter-docker

# cd jmeter-docker
Clone the following repo

15. Now Run the Docker-Compose file

 sudo docker stack deploy -c docker-compose.yml myjm

16. Verify with following command on Master-Node

docker service ls
Verify On Master-Node

17. Now verify on all 3-Slave nodes

docker ps

18. Now Push your .JMX file inside running docker

docker exec -i <container-running-on-master-node> sh -c 'cat > /jmeter/apache-jmeter-2.13/bin/jmeter-docker.jmx' < jmeter-docker.jmx

19. Start the load testing now

# docker exec -it <container-on-master-node> bash

#cd /jmeter/apache-jmeter-2.13/bin

$./jmeter -n -t jmeter-docker.jmx -R < - list of containers running on slave nodes seperated by commas)

20. That’s it.

--

--

Shrihari Haridas
Shrihari Haridas

Written by Shrihari Haridas

Hello everyone, I am Shrihari Haridas I am a Cloud & DevOps Engineer, I work with most of DevOps Tools like, Jenkins, Git, Docker, etc.!& for Cloud AWS