Skip to content

Lingaro/azure-locust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Locust

Run distributed Locust load tests on Azure Container Instances. It's quick, cheap and scalable! Using 20 slaves you can achieve ~12 000 req/s!

Locust Diagram

You can deploy and manage resources using either:

Azure Portal

Make sure you are logged in to Azure Portal.

1. Deployment (Portal)

Click magick button (you can open it in new tab):

Deploy to Azure

Then fill form with given values.

  • Subscription: choose your subscription
  • Resource Group: select existing Resource Group or create new one
  • Location: North Europe (any allowed, but keep in mind its part of Locust DNS address!)
  • Instances (optional): number of slaves (one slave ~600rps)

Custom Deployment

Click Purchase and wait for deployment ends. Follow notifications on Azure Portal:

Notification

Click Go to resource group to verify your deployment:

Resource Group

Go to xxxxxxxxxxxxx-master and find out Locust FQDN - copy it.

Locust Master

2. Go to dashboard (Portal)

When deployment succeeded, your load generator is ready. Go to the above FQDN and port 8089:

http://xxxxxxxxxxxxx-master.northeurope.azurecontainer.io:8089

At this point you can start tests.

Locust Ready

3. Updating script (Portal)

Go to your Resource Group and click Storage Account named xxxxxxxxxxxxx.

Edit Storage

Click File shares (scroll panel down). Go to share called scripts and edit locustfile.py (click ... and edit). Edit contents of your new file and click Save.

Edit Storage

Then restart all containers called like master and slave.

Acis

Click on each container to restart it:

Reset

Tip: This step is really faster using Azure CLI.

4. Cleanup (Portal)

Go to your Resource Group and remove it (it will destroy all resources inside group). You will need to type Resource Group name to confirm.

Remove

Azure CLI

Login and set subscription context

az login
az account set --subscription <SubscriptionId>

1. Deployment (CLI)

Step 1: Setup your names

export RG=<ResourceGroup>

Step 2: Create Resource Group (if not exists)

az group create --name ${RG} --location northeurope

Step 3: Deploy ARM template

az group deployment create --resource-group ${RG} --query properties.outputs --template-file mainTemplate.json 
  • To change number of instances append --parameters instances=<n>

Step 4: Note values of prefix and url from console output.

{
  "outputs": {
    "prefix": {
      "type": "String",
      "value": "xxxxxxxxxxxxx"
    },
    "url": {
      "type": "String",
      "value": "http://xxxxxxxxxxxxx-master.northeurope.azurecontainer.io:8089"
    }
  }
}

2. Go to dashboard (CLI)

When deployment succeeded, your load generator is ready. Go to above url address.

At this point you can start tests.

3. Update script (CLI)

Upload your custom script. Replace account name with above prefix. You can change --source param if you want use different .py file:

az storage file upload --account-name <prefix> -s scripts --source locustfile.py --path locustfile.py

Then restart containers:

az container list --resource-group ${RG} --query '[].name' -o tsv | xargs -I {} az container restart --no-wait --resource-group ${RG} --name {} 

4. Cleanup (CLI)

Remove resources from Azure:

az group delete --name ${RG} --yes

Disclaimer

  • Load test affects target service performance. Never run load tests without service owner permission!
  • Some services can block traffic from generator - you should whitelist Azure Region IPs (Download prefixes).
  • After load tests cleanup Azure resources. You will be billed for running Azure Contianers Instance and Storage Account usage. You can check cost of ACI here.

About

Distributed load tests on Azure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages