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.
Warning
Don’t forget to stop this VM after the lab. It’s EXPENSIVE!
Test Procedure#
Start by creating a VM using gcloud
$ gcloud compute instances create locust-host \ --zone=us-central1-a --machine-type=e2-highcpu-4 \ --create-disk=image=projects/debian-cloud/global/images/family/debian-12,size=10
Now SSH into your new VM. This command establishes a forwarded port.
$ gcloud compute ssh locust-host -- -L 8089:localhost:8089
Install
git
andpip
on your VM$ sudo apt update -y $ sudo apt install -y git python3-pip
Install
locust
on your VM$ pip install locust
Check out your repository on the VM
Note
Retrieve your repo URL from GitHub.
$ git clone https://...
Run locust.
Error
You might have to logout and login again before running
locust
$ cd cis-92 $ locust
Execute a test with the following:
Parameter
Value
Number of Users
8
Ramp Up
1
Host
IP address of your application.
Repeat the test with 1, 2, 3 and 4 replicas and make a note of the performance.
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
Warning
Remember! This is an expensive VM. Turn it off when you’re done with it.