
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Get the sample code and build a Docker image for the application
/ 20
Deploy Web Application
/ 20
Deploy Kubernetes Cluster
/ 20
Load testing master
/ 20
Load testing workers
/ 20
In this lab you will learn how to use Kubernetes Engine to deploy a distributed load testing framework. The framework uses multiple containers to create load testing traffic for a simple REST-based API. Although this solution tests a simple web application, the same pattern can be used to create more complex load testing scenarios such as gaming or Internet-of-Things (IoT) applications. This solution discusses the general architecture of a container-based load testing framework.
For this lab the system under test is a small web application deployed to Google App Engine. The application exposes basic REST-style endpoints to capture incoming HTTP POST requests (incoming data is not persisted).
The application that you'll deploy is modeled after the backend service component found in many Internet-of-Things (IoT) deployments. Devices first register with the service and then begin reporting metrics or sensor readings, while also periodically re-registering with the service.
Common backend service component interaction looks like this:
To model this interaction, you'll use Locust
, a distributed, Python-based load testing tool that is capable of distributing requests across multiple target paths. For example, Locust can distribute requests to the /login
and /metrics
target paths.
The workload is based on the interaction described above and is modeled as a set of Tasks in Locust. To approximate real-world clients, each Locust task is weighted. For example, registration happens once per thousand total client requests.
The Locust container image is a Docker image that contains the Locust software.
A container cluster
consists of at least one cluster master and multiple worker machines called nodes. These master and node machines run the Kubernetes cluster orchestration system.
For more information about clusters, see the Kubernetes Engine documentation
A pod
is one or more containers deployed together on one host, and the smallest compute unit that can be defined, deployed, and managed. Some pods contain only a single container. For example, in this lab, each of the Locust containers runs in its own pod.
A Deployment controller
provides declarative updates for Pods and ReplicaSets. This lab has two deployments: one for locust-master
and other for locust-worker
.
A particular pod can disappear for a variety of reasons, including node failure or intentional node disruption for updates or maintenance. This means that the IP address of a pod does not provide a reliable interface for that pod. A more reliable approach would use an abstract representation of that interface that never changes, even if the underlying pod disappears and is replaced by a new pod with a different IP address. A Kubernetes Engine service
provides this type of abstract interface by defining a logical set of pods and a policy for accessing them.
In this lab there are several services that represent pods or sets of pods. For example, there is a service for the DNS server pod, another service for the Locust master pod, and a service that represents all 10 Locust worker pods.
The following diagram shows the contents of the master and worker nodes:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB home directory and runs on the Google Cloud. Cloud Shell provides command-line access to your Google Cloud resources.
Click Activate Cloud Shell at the top of the Google Cloud console.
Click through the following windows:
When you are connected, you are already authenticated, and the project is set to your Project_ID,
gcloud
is the command-line tool for Google Cloud. It comes pre-installed on Cloud Shell and supports tab-completion.
Output:
Output:
gcloud
, in Google Cloud, refer to the gcloud CLI overview guide.
project id
, region
and zone
you want to use for the lab.app.yaml
file:distributed-load-testing-using-kubernetes
.Example Output:
Click Check my progress to verify the objective.
The sample-webapp
folder contains a simple Google App Engine Python application as the "system under test".
gcloud app deploy
command:After running the command, you'll be prompted with the following.
From the list of regions, you can choose us-central
enter "10" as the input for the prompt.
locust-master
and locust-worker
deployments which is already stored in TARGET
variable.
Click Check my progress to verify the objective.
gcloud
command shown below:Example output:
Click Check my progress to verify the objective.
The first component of the deployment is the Locust master, which is the entry point for executing the load testing tasks described above. The Locust master is deployed with a single replica because we need only one master.
The configuration for the master deployment specifies several elements, including the ports that need to be exposed by the container (8089
for web interface, 5557
and 5558
for communicating with workers). This information is later used to configure the Locust workers.
The following snippet contains the configuration for the ports:
[TARGET_HOST]
and [PROJECT_ID]
in locust-master-controller.yaml
and locust-worker-controller.yaml
with the deployed endpoint and project-id respectively.locust-master
pod is created, run the following command:locust-master-service
:This step will expose the pod with an internal DNS name (locust-master
) and ports 8089
, 5557
, and 5558
. As part of this step, the type: LoadBalancer
directive in locust-master-service.yaml
will tell Google Kubernetes Engine to create a Compute Engine forwarding-rule from a publicly available IP address to the locust-master
pod.
Example output:
Click Check my progress to verify the objective.
The next component of the deployment includes the Locust workers, which execute the load testing tasks described above. The Locust workers are deployed by a single deployment that creates multiple pods. The pods are spread out across the Kubernetes cluster. Each pod uses environment variables to control important configuration information such as the hostname of the system under test and the hostname of the Locust master.
After the Locust workers are deployed, you can return to the Locust master web interface and see that the number of slaves corresponds to the number of deployed workers.
The following snippet contains the deployment configuration for the name, labels, and number of replicas:
locust-worker-controller
:locust-worker-controller
is set to deploy 5 locust-worker
pods. To confirm they were deployed, run the following:Scaling up the number of simulated users will require an increase in the number of Locust worker pods. To increase the number of pods deployed by the deployment, Kubernetes offers the ability to resize deployments without redeploying them.
20
:locust-worker
pods:The following diagram shows the relationship between the Locust master and the Locust workers:
Click Check my progress to verify the objective.
The Locust master web interface enables you to execute the load testing tasks against the system under test.
To begin, specify the total number of users to simulate and a rate at which each user should be spawned.
Next, click Start swarming to begin the simulation. For example you can specify Number of users to simulate as 300 and Hatch rate as 10.
Click Start swarming.
As time progresses and users are spawned, statistics aggregate for simulation metrics, such as the number of requests and requests per second.
You used Kubernetes Engine to deploy a distributed load testing framework.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated October 24, 2024
Lab Last Tested October 24, 2024
Copyright 2025 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
Diese Inhalte sind derzeit nicht verfügbar
Bei Verfügbarkeit des Labs benachrichtigen wir Sie per E-Mail
Sehr gut!
Bei Verfügbarkeit kontaktieren wir Sie per E-Mail
One lab at a time
Confirm to end all existing labs and start this one