12.2. A High Performance VM for Locust#

In order to do proper testing you need a high performance VM with a good network connection. In this lab you will create a VM and use it to test your ability to scale.


Don’t forget to stop this VM after the lab. It’s EXPENSIVE!

Test Procedure#

  1. Start by creating a VM using gcloud

    $ gcloud compute instances create locust-host \
        --zone=us-central1-a --machine-type=e2-highcpu-4 \
  2. Now SSH into your new VM. This command establishes a forwarded port.

    $ gcloud compute ssh locust-host -- -L 8089:localhost:8089
  3. Install git and pip on your VM

    $ sudo apt update -y 
    $ sudo apt install -y git python3-pip
  4. Install locust on your VM

    $ pip install locust
  5. Check out your repository on the VM


    Retrieve your repo URL from GitHub.

    $ git clone https://... 
  6. Run locust.


    You might have to logout and login again before running locust

    $ cd cis-92
    $ locust 

    Execute a test with the following:



    Number of Users


    Ramp Up



    IP address of your application.

  7. Repeat the test with 1, 2, 3 and 4 replicas and make a note of the performance.

  8. Stop the instance.

    $ gcloud compute instances stop locust-host

Stopping the instance halts charges for CPU usage, but there are still small charges for the disk space.

Repeating the Test#

You can repeat the test by restarting the VM:

$ gcloud compute instances start locust-host
$ gcloud compute ssh locust-host -- -L 8089:localhost:8089
$ cd cis-92 
$ locust


Remember! This is an expensive VM. Turn it off when you’re done with it.