Home

Awesome

Docker-Locust

Build Status codecov Codacy Badge

The purpose of this project is to provide a ready and easy-to-use version of locust.io which also contains additional/useful features that are required.

Architecture

Docker-Locust container can be started in 4 different roles:

There are 2 supported run types:

And there are 2 ways to deploy it:

Key advantages

  1. It allows locust to read load test scenario/script from different resources (any HTTP/HTTPS URL, S3 bucket, and local machine).
  2. It has the ability to be run in any CI tool e.g. Jenkins (It can start/stop load test automatically) and provides an HTML report at the end of a load test.
  3. It is also possible to be deployed in AWS to create bigger load.

Requirements

  1. docker engine version 1.9.1+
  2. docker-compose version 1.6.0+ (optional)

Getting Started

Single machine / Standalone mode


docker-locust will be run as standalone version by default. Standalone version is for users who has only 1 single machine.

bash <(curl -s https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/local.sh) deploy

You will be prompted for certains inputs required (You can use our example in github as load test script).

Target url: https://targeturl.com
Where load test script is stored: https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/simple.py
Number of slave(s): 4
Run type [automatic/manual]: manual

All of it can be simplify in one line:

bash <(curl -s https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/local.sh) deploy --target=https://targeturl.com --locust-file=https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/simple.py --slaves=4 --mode=manual

It is also possible to run with normal docker command:

docker run -i --rm -v $PWD/reports:/opt/reports -v ~/.aws:/root/.aws -v $PWD/:/opt/script -v $PWD/credentials:/meta/credentials -p 8089:8089 -e ROLE=standalone -e TARGET_HOST=https://targeturl.com -e LOCUST_FILE=https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/simple.py -e SLAVE_MUL=4 -e AUTOMATIC=False registry.opensource.zalan.do/tip/docker-locust

Multiple machines


docker-locust can be run in multiple docker-containers. It is useful for users who has more than one machine to create bigger load. In this point we are using docker-compose, but it is also possible to run it in different ways, e.g. Cloudformation in AWS.

Run the application with the command:

DOCKER_COMPOSE=true bash <(curl -s https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/local.sh) deploy

Read multiple files

docker-locust has the ability to read multiple files from s3 or any http/https, e.g. 1 file is the load test file / python file and 1 other file is json file where payloads are stored. Sample command:

bash <(curl -s https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/local.sh) deploy --target=https://targeturl.com --locust-file=https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/simple_post.py,https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/payloads.json --slaves=4 --mode=manual

Report Generation

Please add following lines to your load test script, like this example.

from locust.web import app
from src import report
app.add_url_rule('/htmlreport', 'htmlreport', report.download_report)

Simply after load test run, append "/htmlreport" to the URL which will download the report of the recent run. Example:

Setup in jenkins

docker-locust can be run automatically by using CI tool like jenkins.

Sample case:

Steps:

  1. Put following command in "Execute shell" field:

    curl -O https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/local.sh && DOCKER_COMPOSE=true bash local.sh deploy --target=https://targeturl.com --locust-file=https://raw.githubusercontent.com/zalando-incubator/docker-locust/master/example/simple.py --slaves=4 --mode=automatic --users=100 --hatch-rate=5 --duration=30
    
  2. Install html-publisher-plugin in jenkins to display load test result. Example configuration in jenkins job:

Troubleshooting

All output from containers can be see by running:

docker-compose logs -f

About the project versioning

A version number is combination between the locust version being supported and patch level, e.g. when a release is 0.7.3-p0, it support locust 0.7.3.

Capacity of docker-locust in AWS

All the data based on load testing against simple hello-world application with the default max_wait and min_wait values (1000ms).

No.Group TypeEC2vCPURAM (GiB)Clock Speed (GHz)Enhanced NetworkingMax total RPS that can be created per 1 slave machine (rough number)Price per hour (EU - Frankfurt)RPS per cent
1General Purposet2.nano10.5up to 3.3-200$0.0068294.12
2General Purposet2.micro11up to 3.3-500$0.014357.14
3General Purposet2.small12up to 3.3-500$0.027185.19
4General Purposet2.medium24up to 3.3-1100$0.054203.7
5General Purposet2.large28up to 3.0-1100$0.108101.85
6General Purposet2.xlarge416up to 3.0-2200$0.216101.85
7General Purposet2.2xlarge832up to 3.0-4700$0.432108.8
8General Purposem4.large282.4Yes700$0.1258.33
9General Purposem4.xlarge4162.4Yes1500$0.2462.5
10General Purposem4.2xlarge8322.4Yes2500$0.4852.08
11General Purposem4.4xlarge16642.4Yes6500$0.9667.71
12General Purposem4.10xlarge401602.4Yes10000$2.441.67
13General Purposem4.16xlarge642562.3Yes17000$3.8444.27
14General Purposem3.medium13.752.5-250$0.07931.65
15General Purposem3.large27.52.5-600$0.15837.97
16General Purposem3.xlarge4152.5-1300$0.31541.27
17General Purposem3.2xlarge8302.5-2600$0.63241.14
18Compute Optimizedc4.large23.752.9Yes800$0.11470.18
19Compute Optimizedc4.xlarge47.52.9Yes1600$0.22770.48
20Compute Optimizedc4.2xlarge8152.9Yes2500$0.45455.07
21Compute Optimizedc4.4xlarge16302.9Yes6500$0.90971.51
22Compute Optimizedc4.8xlarge36602.9Yes12500$1.81768.79
23Compute Optimizedc3.large23.752.8Yes650$0.12950.39
24Compute Optimizedc3.xlarge47.52.8Yes1300$0.25850.39
25Compute Optimizedc3.2xlarge8152.8Yes2500$0.51648.45
26Compute Optimizedc3.4xlarge16302.8Yes5500$1.03253.29
27Compute Optimizedc3.8xlarge32602.8Yes9000$2.06443.6

NOTE:

  1. Please check AWS-EC2-Type and AWS-EC2-pricing before use data above, because some of them could be changed time to time.
  2. Number of total RPS could be different because of n reasons.

Contributions

Any feedback or contributions are welcome! Please check our guidelines.

Unit tests

Run the unit tests with this command:

local.sh test

License

See License

Security

See Security