Load testing using multiple agents
You can use Load Testing to test your service with multiple agents.
You can use multiple agents for load testing when:
- The test target includes multiple instances, and the total incoming and outgoing traffic from them does not exceed the capacity of one agent.
- Requests to the test target require significant computing capacity.
- Using a test target is much more effective than a load generator.
Agents launch and load the test target synchronously. Test results are available as cumulative and independent reports on each agent.
To run a load test using multiple agents:
- Get your cloud ready.
- Set up your infrastructure.
- Create a test agent.
- Run the test.
- View the testing results.
If you no longer need the resources you created, delete them.
Getting started
Sign up in Yandex Cloud and create a billing account:
- Navigate to the management console
and log in to Yandex Cloud or register a new account. - 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 and link a cloud to it.
If you have an active billing account, you can navigate 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.
Set up your infrastructure
Create a service account
- Create a service account named
sa-loadtest
in the folder where the agents will reside. - Assign the
loadtesting.generatorClient
role to the service account.
Configure your 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 load the test 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, an external service named example.myservice.ru
will be loaded. 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 the agent. -
In the list of services, select Load Testing.
-
In the
Agents tab, click Create agent. -
Enter a name for the agent, e.g.,
agent-008
. -
Select an availability zone to host the agent.
-
Under Agent:
- Select the appropriate agent type.
- Specify the subnet to host the agent. Make sure you created and set up a NAT gateway in the subnet.
- If you can use security groups, select a preset agent security group.
-
Under Access, specify the agent access credentials:
-
Select the
sa-loadtest
service account. -
Under Login, enter the username.
Alert
Do not use
root
or other reserved usernames. To perform operations requiring root privileges, use thesudo
command. -
In the SSH key field, paste the contents of the public key file.
-
-
Click Create.
-
Wait until the VM instance is created. Make sure the agent status has changed 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 a public IP address and access to
loadtesting.api.cloud.yandex.net:443
. - A NAT gateway is set up in the target subnet.
- The service account assigned to the agent has the required roles.
- The agent has a public IP address and access to
-
-
Follow the same steps 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 the 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
agent-008
.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: Enter
80
(default port for the HTTP protocol). - Testing threads: Enter
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. Learn more about testing threads.
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 tagged
index
andget_test
. The load generator will repeat them alternately within the specified 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 that each connection will be closed following the request. This mode is heavier on the tested service and load generator. If you do not want the connections closed, setKeep-Alive
.
-
-
Under Forced test termination time, specify the time after which the test will autostop, unless it is stopped for other reasons. Set it to be slightly greater than the expected test duration.
- 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
agent-009
. -
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 criterion will stop the test if over 90% of the testing threads are busy 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 easier to read.
- Click Create.
The configurations will be checked, and the agents will start loading the service. You can check 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 using multiple agents have the
Multi
label. - To view cumulative results, go to the Test results tab.
- To view the test results for each agent individually:
- Navigate to the Overview tab.
- Select the agent under Tests.
- Navigate to the Test results tab.
How to delete the resources you created
To stop paying for the resources you created, delete the testing agents.