AWS Elastic Beanstalk sample code to run the load testing tool, locust.
This sample application uses the Locust open source load testing tool to create a simple load generator for your applications. The sample test definition locustfile.py tests the root of an endpoint passed in as an environment variable (TARGET_URL). For more information on the format of the test definition file, see Writing a locustfile.
You can get started using the following steps:
eb init -r <region> -p "Java 8"
to initialize the folder for use with the CLI. Replace <region>
with a region identifier such as us-west-2
(see Regions and Endpoints for a full list of region identifiers). For interactive mode, run eb init
then,
eb create -i c4.large --scale 1 --envvars TARGET_URL=<test URL> --instance_profile aws-elasticbeanstalk-locust-role
to begin the creation of your load generation environment. Replace <test URL>
with the URL of the web app that you want to test.eb open
to open the Locust dashboard and start your tests.eb deploy
.eb scale <number of instances>
. Replace <number of instances>
with the number of EC2 instances you would like the environment to scale out to.eb deploy
to reselect the master instance removal has been completed.eb open
to open the Locust dashboard and start your tests.eb terminate --all
to clean up.Note: Running Locust in distributed mode requires a master/slave architecture. This sample requires that the auto scaling minimum and maximum be set to the same value to ensure that the master isn’t terminated by auto scaling. If for some reason the master instance is replaced, an eb deploy
should be all it takes to fix it.