Running Locust inside Lando Dev Tool

Submitted by galactus on Sun, 01/12/2020 - 06:20

In this blog post, I'm going to talk about how to setup Locust inside the Lando Dev Tool.

First, let's discuss what are these tools are.

Lando vastly simplifies local development and DevOps so you can focus on what's important; delivering value to your clients and customers. - (What I love here is I don't need to setup my docker container from the scratch it is already bundle and configured in Lando. I can easily destroy the instance whenever I wanted and spin up new one.)

Locust is an open source load testing tool. -

Note: I'm not going to cover how to setup Lando in a local machine I assume you already have. If you don't have Lando installed in your machine you can check the guide here: 

Let's get started...

  1. In your local machine create a folder name mylocust.
    mkdir mylocust
  2. Navigate inside the folder.
    cd mylocust
  3. Create .lando.yml file copy and paste the content below in your file.
    name: mylocust
        type: python:3.7
        port: 80
        ssl: false
        command: locust
          - /usr/local/bin/python -m pip install --upgrade pip
          - pip3 install locust
        service: appserver
  4. Create file. Here we define a number of Locust tasks. We just copy the contents of the file here: - you can replace it with your own site information.
    from locust import HttpLocust, TaskSet, between
    def login(l):"/login", {"username":"ellen_key", "password":"education"})
    def logout(l):"/logout", {"username":"ellen_key", "password":"education"})
    def index(l):
    def profile(l):
    class UserBehavior(TaskSet):
        tasks = {index: 2, profile: 1}
        def on_start(self):
        def on_stop(self):
    class WebsiteUser(HttpLocust):
        task_set = UserBehavior
        wait_time = between(5.0, 9.0)
  5. Start Lando.
    lando start

    Initializing installation process...lando-start

  6. Visit Lando generated URL.locust-webpage

Congratulations! you now have Locust running inside your Lando instance.