Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • Enabling a blue-green and canary deployment of web service versions
    • Automating image builds using Jenkins and Packer
    • Continuous deployment of containerized applications using GitLab
    • App testing with GitLab
    • Creating test VMs using GitLab CI
    • GitLab integration with Tracker
    • High-performance computing on preemptible VMs
    • Load testing a gRPC service
    • Fixed-load HTTPS testing with Phantom
    • Step-load HTTPS testing with Pandora
    • Scripted HTTP load testing with Pandora
    • Load testing using multiple agents
    • Migrating load testing results from OverLoad
    • Running external agents for load testing
    • JMeter load testing
    • Getting statistics on queries to Object Storage objects using Query
    • Getting the number of queries to Object Storage objects
    • Invoking load testing from GitLab CI
    • Comparing load test results
    • Deploying GitLab Runner on a Compute Cloud virtual machine

In this article:

  • Prepare your cloud
  • Required paid resources
  • Prepare a test target
  • Prepare the infrastructure
  • Create a service account
  • Configure a network
  • Configure security groups
  • Create a test agent
  • Prepare a file with test data
  • Prepare a script file
  • Run a test
  • How to delete the resources you created
  1. Development and testing
  2. Scripted HTTP load testing with Pandora

Scripted HTTP load testing with Pandora

Written by
Yandex Cloud
Updated at May 7, 2025
  • Prepare your cloud
    • Required paid resources
  • Prepare a test target
  • Prepare the infrastructure
    • Create a service account
    • Configure a network
    • Configure security groups
  • Create a test agent
  • Prepare a file with test data
  • Prepare a script file
  • Run a test
  • How to delete the resources you created

You can use Load Testing to run scripted load tests over HTTP with the Pandora load generator.

To perform load testing:

  1. Prepare your cloud.
  2. Prepare a test target.
  3. Prepare your infrastructure.
  4. Create an agent.
  5. Prepare a file with test data.
  6. Prepare a script file.
  7. Run a test.

If you no longer need the resources you created, delete them.

Prepare your cloudPrepare your cloud

Sign up in Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or register a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_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 to create or select a folder for your infrastructure to operate in.

Learn more about clouds and folders.

Required paid resourcesRequired 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 a test targetPrepare a test target

In this example, we will test a service with internal IP address 172.17.0.10 in the same subnet as the agent.

Make sure the service is accessed over HTTPS using the default port: 443.

You can also use Load Testing for load testing of a service that is public or located in a subnet and security group other than those of the agent.

For a public service, allow incoming HTTPS traffic on port 443.

For a service whose subnet and security group is different from the agent's ones, create a rule for incoming HTTPS traffic on port 443 in the security group where the test target is located.

Prepare the infrastructurePrepare the infrastructure

Create a service accountCreate a service account

  1. Create a service account named sa-loadtest in the folder to host the agent that will generate the load.
  2. Assign the following roles to the service account:
    • loadtesting.generatorClient: Allows running the agent, performing tests on the agent, and uploading the results to storage.
    • compute.admin: Allows managing VMs in Compute Cloud.
    • vpc.user: Allows connecting to Virtual Private Cloud network resources and using them.

Configure a networkConfigure a network

Create and configure a NAT gateway in the subnet where your test target is and where the agent will reside. This will enable the agent to access Load Testing.

Configure security groupsConfigure security groups

  1. Set up the test agent's security group:

    1. Create an agent security group named agent-sg.
    2. Add rules:
      1. 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 connecting the agent to Load Testing to manage tests from the interface and get test results.

      2. Rule 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.

      3. Rule for outgoing traffic when generating load to the test target:

        • Port range: 0-65535
        • Protocol: Any
        • Destination name: Security group
          Select From list. Specify the security group where the test target is located.

        Create this rule for each test target with a unique security group.

  2. Set up the test target's security group:

    1. Create the test target's security group named load-target-sg.

    2. Add a rule for incoming traffic when generating load to the test target:

      • Port range: 0-65535.
      • Protocol: Any.
      • Select From list. Specify the security group where the test target is located.

      This rule allows agents to generate load to this target or enable additional monitoring tools.

Create a test agentCreate a test agent

  1. If you do not have an SSH key pair yet, create one.

  2. Create an agent.

    Management console
    CLI
    1. In the management console, select the folder where you want to create the agent.

    2. From the list of services, select Load Testing.

    3. In the Agents tab, click Create agent.

    4. Enter a name for the agent, e.g., agent-008.

    5. Specify the same availability zone where the test target is located.

    6. Under Agent:

      • Select the appropriate agent type. For more information, see Agent performance.
      • Specify the subnet where the test target is located. 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.
    7. Under Access, specify the information required to access the agent:

      • Select the sa-loadtest service account.

      • Under Login, enter a username.

        Alert

        Do not use root or other reserved usernames. To perform operations requiring root privileges, use the sudo command.

      • In the SSH key field, paste the contents of the public key file.

    8. Click Create.

    9. Wait for the VM instance to create. Make sure the agent status has changed to Ready for test.

      Note

      If the agent creation process has stopped at Initializing connection, make sure 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.

    If you do not have the Yandex Cloud CLI yet, install and initialize it.

    The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

    1. See the description of the CLI command for creating an agent:

      yc loadtesting agent create --help
      
    2. Select the same availability zone where the test target is located.

    3. Select the subnet where the test target is located. Make sure you created and set up a NAT gateway in the subnet.

      To get a list of available subnets using the CLI, run this command:

      yc vpc subnet list
      

      Result:

      +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
      |          ID          |           NAME            |      NETWORK ID      | ROUTE TABLE ID |       ZONE        |      RANGE      |
      +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
      | e2lfkhps7bol******** |   default-ru-central1-b   | enpnf7hajqmd******** |                |   ru-central1-b   | [10.129.0.0/24] |
      | e9bgnq1bggfa******** |   default-ru-central1-a   | enpnf7hajqmd******** |                |   ru-central1-a   | [10.128.0.0/24] |
      | fl841n5ilklr******** |   default-ru-central1-d   | enpnf7hajqmd******** |                |   ru-central1-d   | [10.130.0.0/24] |
      +----------------------+---------------------------+----------------------+----------------+-------------------+-----------------+
      
    4. Select the security group. Make sure to configure the security group in advance.

      To get a list of available security groups using the CLI, run this command:

      yc vpc security-group list
      

      Result:

      +----------------------+---------------------------------+--------------------------------+----------------------+
      |          ID          |              NAME               |          DESCRIPTION           |      NETWORK-ID      |
      +----------------------+---------------------------------+--------------------------------+----------------------+
      | enp414a2tnnp******** | default-sg-enpnf7hajqmd******** | Default security group for     | enpnf7hajqmd******** |
      |                      |                                 | network                        |                      |
      | enpctpve7951******** | sg-load-testing-agents          |                                | enpnf7hajqmd******** |
      | enpufo9ms0gi******** | sg-load-testing-targets         |                                | enpnf7hajqmd******** |
      +----------------------+---------------------------------+--------------------------------+----------------------+
      
    5. Find out the sa-loadtest service account ID using its name:

      yc iam service-account get sa-loadtest
      

      Result:

      id: ajespasg04oc********
      folder_id: b1g85uk96h3f********
      created_at: "2024-12-04T17:38:57Z"
      name: sa-loadtest
      last_authenticated_at: "2024-12-12T19:10:00Z"
      
    6. Create an agent in the default folder:

      yc loadtesting agent create \
        --name agent-008 \
        --labels origin=default,label-key=label-value \
        --zone default-ru-central1-a \
        --network-interface subnet-id=e9bgnq1bggfa********,security-group-ids=enpctpve7951******** \
        --cores 2 \
        --memory 2G \
        --service-account-id ajespasg04oc********
        --metadata-from-file user-data=metadata.yaml
      

      Where:

      • --name: Agent name.
      • --labels: Agent labels.
      • --zone: Availability zone to host the agent.
      • --network-interface: Agent network interface settings:
        • subnet-name: ID of the selected subnet.
        • security-group-ids: Security group IDs.
      • --cores: Number of CPU cores the agent can use.
      • --memory: Amount of RAM allocated to the agent.
      • --service-account-id: Service account ID.
      • --metadata-from-file: <key>=<value> pair with the name of the file containing the public SSH key path. For an example of the metadata.yaml configuration file, see VM metadata.

      For more information on how to create an agent with CLI, see the Yandex Cloud Examples repository.

  3. Assign a public IP to the agent to enable access over SSH:

    Management console
    CLI
    1. In the management console, select the folder where the agent is located.
    2. Select Compute Cloud.
    3. Select the VM named agent-008.
    4. Under Network interface, in the top-right corner, click and select Add public IP address.
    5. In the window that opens:
      • In the Public address field, select obtaining a Auto address.
      • Click Add.

    To assign a public IP address to an agent, run the following CLI command:

    yc compute instance add-one-to-one-nat \
      --id=<VM_ID> \
      --network-interface-index=<VM_network_interface_number> \
      --nat-address=<IP_address>
    

    Where:

    • --id: VM ID. You can get a list of available VM IDs in a folder using the yc compute instance list CLI command.

    • --network-interface-index: VM network interface number. The default value is 0. To get a list of VM network interfaces and their numbers, run the following command: yc compute instance get <VM_ID>.

    • --nat-address: Public IP address to assign to the VM. This is an optional parameter. If you omit it, a public IP address will be assigned to the VM automatically.

      You can get a list of reserved public IP addresses available in a folder using the yc vpc address list CLI command. The IP address and the VM must be in the same availability zone.

    Usage example:

    yc compute instance add-one-to-one-nat \
      --id=fhmsbag62taf******** \
      --network-interface-index=0 \
      --nat-address=51.250.*.***
    

    Result:

    id: fhmsbag62taf********
    folder_id: b1gv87ssvu49********
    created_at: "2022-05-06T10:41:56Z"
    ...
    network_settings:
      type: STANDARD
    placement_policy: {}
    

    For more information about the yc compute instance add-one-to-one-nat command, see the CLI reference.

Prepare a file with test dataPrepare a file with test data

  1. Generate test data in the users.csv file:

    user_id,name,pass
    1,John,123
    2,Jack,456
    3,Jim,789
    4,Joe,0asdf
    5,Jane,12dasdf
    6,Jill,asdf
    7,Joy,zxcv
    8,Joy,zxcv
    9,Joy,zxcv
    10,Joy,zxcv
    

Prepare a script filePrepare a script file

In your test script, specify a sequence of HTTP requests to run during testing. A single file may include multiple scripts. The following file formats are supported:

  • hcl
  • yaml
  • json
  1. Prepare your script in the payload.hcl file:

    variable_source "variables" "variables" {
       variables = {
          auth_path = "/auth"
          order_path = "/order"
       }
    }
    
    
    variable_source "users" "file/csv" {
       file              = "users.csv"
       fields            = ["user_id", "name", "pass"]
       ignore_first_line = true
       delimiter         = ","
    }
    
    request "auth_req" {
       method  = "POST"
       uri     = "{{.source.variables.auth_path}}"
       headers = {
          Content-Type = "application/json"
          Useragent    = "Yandex"
       }
       body = <<EOF
    {"user_id":  {{.request.auth_req.preprocessor.user_id}}}
    EOF
       tag  = "auth"
    
       preprocessor {
          mapping = {
             user_id = "source.users[next].user_id"
          }
       }
    }
    
    request "order_req" {
       method  = "POST"
       uri     = "{{.source.variables.order_path}}?sleep=100"
       headers = {
          Useragent     = "Yandex"
       }
       body = <<EOF
    {"item_id": test_item_id}
    EOF
       tag  = "order"
    }
    
    scenario "test_scenario" {
       min_waiting_time = 1000
       requests = [
          "auth_req",
          "sleep(100)",
          "order_req(3, 100)"
       ]
    }
    

    This script named test_scenario describes the requests named auth_req and order_req: You can provide arguments to a request to set the number of its runs and the delay time between them. In this example, order_req(3, 100) means that order_req will run three times with an interval of 100 milliseconds.

    The min_waiting_time parameter defines the minimum script execution time in milliseconds. If a script is completed faster, the remaining time will be appended to the script as a delay.

    The script features a variable source called variables containing the auth_path and order_path variables. Their values are used to specify uri in requests.

    Also, the script includes the users variable source which uses the data from the external users.csv file. To work with an array of users, the script employs a preprocessor with the following modifiers:

    • next to get the next array element.
    • last to get the last array element.
    • rand to get a random array element.

Run a testRun a test

  1. In the management console, select Load Testing.

  2. In the left-hand panel, select Tests. Click Create test.

  3. In the Agents parameter, select agent-008.

  4. Under Attached files, click Select files and select the users.csv and payload.hcl files you saved earlier.

  5. Under Test settings, select the Config configuration method.

  6. In the configuration input field, specify the testing thread settings in yaml format:

       uploader:
          enabled: true
          package: yandextank.plugins.DataUploader
          api_address: loadtesting.api.cloud.yandex.net:443
       pandora:
          enabled: true
          package: yandextank.plugins.Pandora
          config_content:
             pools:
                - id: Pool name
                   gun:
                      type: http/scenario
                      target: 172.17.0.10:80
                   ammo:
                      type: http/scenario
                      file: payload.hcl
                   result:
                      type: phout
                      destination: ./phout.log
                   rps:
                      - duration: 10s
                         type: line
                         from: 1
                         to: 5
                   startup:
                      type: once
                      times: 5
             log:
                level: debug
       autostop:
          enabled: true
          package: yandextank.plugins.Autostop
          autostop:
             - limit (5m)
       core: {}
    
  7. Click Create.

Once you do that, the configuration will pass checks, and the agent will start loading the service you are testing.

To see the testing progress, select the new test and go to the Test results tab.

How to delete the resources you createdHow to delete the resources you created

Some resources are not free of charge. To avoid paying for them, delete the resources you no longer need:

  1. Delete the agent.
  2. Delete the route table.
  3. Delete the NAT gateway.

Was the article helpful?

Previous
Step-load HTTPS testing with Pandora
Next
Load testing using multiple agents
© 2025 Direct Cursus Technology L.L.C.