https://github.com/dbwodlf3/locust-cluster-docker
https://github.com/dbwodlf3/locust-cluster-docker
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dbwodlf3/locust-cluster-docker
- Owner: dbwodlf3
- Created: 2021-09-14T08:46:07.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-11T05:50:09.000Z (over 2 years ago)
- Last Synced: 2025-01-05T14:23:53.591Z (5 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# build
docker build -t locust-cluster ./
# docker compose
cd ./test && docker-compose up -d
# stack
cd ./test && docker stack deploy -c ./stack.yml locust-cluster
## AWS Example
### 1. Create AMI, Create Template
```Connect```
Create ec2 instance. I selected t4g.small aws linux 2. You need to open port 22 for ssh and 9000 for locust web interface via aws secuirity group.
And connect to the instance. i used visual studio code remote ssh extension.If you use visual studio code, then Ctrl + Shift + X and search Remote SSH extension.
next Ctrl + Shift + P execute Remote-SSH: Open SSH Configuration File.
and set like below.
```
Host AWS-LOCUST
HostName your-ec2-ip
User ec2-user
IdentityFile C:\Users\home\Desktop\your-key.pem
```next Ctrl + Shift + P, Remote-SSH: Connect to Host, Select AWS-LOCUST.
```Source```
```
sudo yum install git docker -y
sudo systemctl enable docker
sudo systemctl start dockergit clone https://github.com/dbwodlf3/locust-cluster-docker.git
cd locust-cluster-docker
sudo docker build ./ -t locust-clustersudo docker swarm init
cd test
docker stack deploy -c ./stack.yml locust-cluster# check it works.
curl locahlost:9000
```and open it with your web browser.
```http://your-ec2-public-ip:9000```
everything works then create AMIs from this ec2 instance.```Launch Template```
Select the AMI, security group opend port, the ec2 instance type as t4g.small, the key pair and then create launch template.
This is be a master node.And then will make a worker node.
create ec2 instance from the AMI.
```
# Worker EC2 instance
sudo docker swarm leave --force && sudo docker swarm leave
```Then also create Worker AMI and Worker Launch Template this will be used for autoscaling.
And add template initalize shell code.
(Template Advanced details, User data)
```
#/bin/sh
sudo docker swarm join --token your-token-key your-ip:port
```### 2. Register Autoscaling Group
Create Target groups.
Choose a target type as Instances.
Select properly VPC.(select the same vpc as your EC2 template)
And then make it.Create Application Load Balancer.
Select properly VPC.(select the same vpc as your EC2 template)
Select the target group made just before
And then make it.Create Autoscaling Group
Select properly launch template, properly VPC, properly load balancer and make it.### 3. Test
Release a autoscaling group.
and in master node you can chek it works.
```
sudo node ls
```And make your test script and run it.
edit my_locustfile.py and update stack.
```
docker stack deploy -c ./stack.yml locust-cluster
```