Load testing using multiple agents
You can use Yandex Load Testing to test the service with multiple testing agents.
Load testing using multiple agents is used when:
- The testing target includes several instances, and the total inbound and outgoing traffic from them doesn't exceed the capacity of one agent.
- The requests being sent to the testing target require large computing capacity.
- Using a testing target is much more effective than a load generator.
Agents start and apply the load on the testing target synchronously. The testing results are available as generalized and independent reports on each agent.
To run the load testing using multiple agents:
- Prepare your cloud.
- Prepare the infrastructure.
- Create a test agent.
- Run a test.
- View the testing results.
If you no longer need the resources you created, delete them.
Getting started
Sign up for Yandex Cloud and create a billing account:
- Go to the management console
and log in to Yandex Cloud or create an account if you do not have one yet. - On the Yandex Cloud Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
If the agent is hosted on Yandex Cloud, a fee is charged for computing resources (see Yandex Compute Cloud pricing).
At the Preview stage, Load Testing can be used free of charge.
Prepare the infrastructure
Create a service account
- Create a service account named
sa-loadtest
in the folder where you are going to place agents. - Assign the service account the
loadtesting.generatorClient
role.
Configure a network
Set up an NAT gateway in the subnet where you are going to place your agents. This ensures the agents have access to Load Testing.
Configure the security group
- For the agents, create a security group named
agent-sg
. - Add rules:
-
Rule for outgoing HTTPS traffic to the Yandex Load Testing public API:
- Port range:
443
. - Protocol:
TCP
. - Destination name:
CIDR
. - CIDR blocks:
0.0.0.0/0
.
This will enable you to connect the agent to Load Testing so as to control the tests from the interface and get the test results.
- Port range:
-
A rule for outgoing HTTP traffic when generating load to the test target:
- Port range:
80
. - Protocol:
TCP
. - Destination name:
CIDR
. - CIDR blocks:
0.0.0.0/0
.
This enables the agents to apply the load on the testing target.
- Port range:
-
Rules for incoming SSH-traffic:
- Port range:
22
. - Protocol:
TCP
. - Destination name:
CIDR
. - CIDR blocks:
0.0.0.0/0
.
This lets you connect to the agent over SSH and control tests from the console or collect debugging information.
- Port range:
-
In this example, the load will be applied to an external service named example.myservice.ru
. For more information about setting up security groups for testing the services running inside the cloud, see:
Create test agents
-
If you do not have an SSH key pair yet, create them.
-
Create the first agent:
Management console-
In the management console
, select the folder where you want to create your agent. -
In the list of services, select Load Testing.
-
In the
Agents tab, click Create agent. -
Give your agent a name, e.g.,
agent-008
. -
Select an availability zone to place the agent in.
-
Under Agent:
- Select the appropriate agent type. For more information, see Agent performance.
- Specify the subnet to place the agent in. Make sure you created and set up a NAT gateway in the subnet.
- If security groups are available to you, select a security group preset for the agent.
-
Under Access, specify the information required to access the agent:
-
Select the
sa-loadtest
service account. -
Enter the username in the Login field.
Alert
Do not use the
root
username or other names reserved by the operating system. To perform operations that require superuser permissions, use thesudo
command. -
In the SSH key field, paste the contents of the public key file.
-
-
Click Create.
-
Wait for the VM instance to create. Make sure the agent status changes to
Ready for test
.Note
The agent creation process may stop at the
Initializing connection
status unless the following conditions are met:
-
-
Create the second agent named
agent-009
.
If you need to connect to the agents over SSH, assign to them a public IP address.
Run a test
-
In the management console
, select Load Testing. -
In the left-hand panel, select
Tests. -
Click Create test.
-
Under Config 1, specify the test parameters for the first agent:
-
Agents: Select the
agent-008
agent.In this example, the agents will have different test configurations. To use the same configuration, in the Agents field, select all the agents you need to use.
-
Under Test settings:
-
Configuration method: Select
Form
. -
Load generator: Select
Pandora
. -
Target address: Enter the address of the service to test:
example.myservice.ru
. -
Target port: Set to
80
(default port for the HTTP protocol). -
Testing threads:
1000
.This means that the load generator can simultaneously process 1000 operations: either create 1000 connections or wait for 1000 responses from the service at the same time. You can learn more about testing pipelines here.
Warning
Make sure the agent has access to
example.myservice.ru:80
. -
In the Load type menu:
-
Select the
RPS
type. -
Add a Load profile:
- Profile 1: Select
line
. - From: Set
1
. - To: Set
100
. - Duration: Specify
60s
.
- Profile 1: Select
-
Add another Load profile:
- Profile 2: Select
const
. - Responses per second: Set
100
. - Duration: Specify
300s
.
This instructs the generator to increase the load from 1 to 100 requests per second for the first 60 seconds, and then maintain a load of 100 requests per second for 5 minutes. Learn more about the load profile.
- Profile 2: Select
-
-
Request type: Specify
URI
as the type. -
In the Set requests via form menu:
-
In the Requests submenu, add the following requests:
/ index
/test?param1=1¶m2=2 get_test
The requests are marked with the
index
andget_test
tags. The load generator will repeat them within a given load profile.
-
-
In the Request headers submenu, specify the following headers:
[Host: example.myservice.ru]
[Connection: Close]
Please note that the
Connection: Close
header means each connection is terminated after making a request. This mode is heavier on the tested service and load generator. If you do not need to close connections, setKeep-Alive
.
-
-
-
Click
Duplicate configuration. The test parameters will be copied to the Config 2 section. -
Under Config 2, specify the test parameters for the second agent:
-
Agents: Select the
agent-009
agent. -
Under Test settings, change the testing parameters.
For example, in the Autostop menu, click
Autostop and enter the following description:- Autostop type:
INSTANCES
. - Set Limit to
90%
. - Window duration:
60s
.
This means a test will be stopped if 90% of testing threads are used for 60 seconds, which indicates a testing issue. Learn more about autostop.
- Autostop type:
-
-
Under Test information, specify the name, description, and number of the test version. This will make the reports readable.
-
Click Create.
Once you are done, the configurations will be verified and the agents will start loading the application being tested. You can view the report on the Tests tab.
View the testing results
- In the management console
, select Load Testing. - In the left-hand panel, go to the
Tests tab. - Select the test that you created previously. Test with multiple agents have the
Multi
label. - To view generalized results, go to the tab Test results.
- To view the test results for each agent individually:
- Go to Overview.
- Select an appropriate agent under Tests.
- Go to Test results.
How to delete the resources you created
To stop paying for the resources created, delete the testing agents.