Load testing using multiple agents
You can use Load Testing to test the service with multiple testing agents.
Load testing using multiple agents is used when:
- The testing target includes multiple instances, and the total inbound and outgoing traffic from them does not exceed the capacity of one agent.
- The requests 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 your 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, you pay for computing resources (see Yandex Compute Cloud pricing).
At the Preview stage, Load Testing is 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 a NAT gateway in the subnet to host the agents. This will allow the agents to access 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 Load Testing public API:
- Port range:
443
- Protocol:
TCP
- Destination name:
CIDR
- CIDR blocks:
0.0.0.0/0
This will allow you to connect the agent to Load Testing and manage the tests using the interface and get the test results.
- Port range:
-
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 will allow you to connect to the agent over SSH and manage 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 one.
-
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.
- 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
root
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 be created. 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:- The agent has access to
loadtesting.api.cloud.yandex.net:443
and is assigned a public IP address. - A NAT gateway is set up in the target subnet.
- The service account assigned to the agent has the required roles.
- The agent has access to
-
-
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 Configuration 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 1,000 operations: either create 1,000 connections or wait for 1,000 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:
Line
- From:
1
- To:
100
- Duration:
60s
- Profile 1:
- Add another Load profile:
- Profile 2:
Const
- Responses per second:
100
- Duration:
300s
- Profile 2:
This instructs the load 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.
- Select the
-
Request type: Specify
URI
as the type. -
In the Attached files field, select Form. In the menu that opens:
- In the Requests menu, 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 Requests menu, add the following requests:
-
In the Request headers menu, 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
.
-
-
Under Forced test termination time, specify the time to autostop the test unless it is stopped for other reasons. The parameter value should be slightly greater than the expected duration of the test.
- Configuration method: Select
-
- Click
Duplicate configuration. The test parameters will be copied to the Configuration 2 settings. - Under Configuration 2, specify the test parameters for the second agent:
-
Agents: Select the
agent-009
agent. -
Under Test settings, change the test parameters.
For example, in the Autostop menu, click
Autostop and enter the following description:- Autostop type:
INSTANCES
- Limit:
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.
- 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 earlier. Tests with multiple agents have the
Multi
label. - To view generalized results, go to the Test results tab.
- 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 you created, delete the testing agents.