Skip to main content
Create a load balancer
Last update:

Create a load balancer

  1. Select the configuration and network.
  2. Create a task force.
  3. Create rules and HTTP policies.

1. Select the configuration and network

  1. In the Control panel, on the top menu, click Products and select Cloud Servers.

  2. Go to BalancersBalancers tab.

  3. Click Create Balancer.

  4. Select the region and pool where the balancer will be created.

  5. Select a configuration based on the project load.

  6. Enter the name of the balancer.

  7. Optional: enter a comment — any additional information about the balancer, it will only be displayed in the control panel.

  8. Optional: To access the balancer logs, enable logging. Logging uses part of the balancer's computational resources.

    8.1 Check the Collect balancer technical logs checkbox.

    8.2 Select a log group or create a new group.

    8.3 If you have selected a new group, enter its name.

  9. Select a subnet:

    • private — traffic balancing will be performed only within the subnet. You can connect a public IP address to a private address — the balancer will be accessible from the Internet via NAT;
    • or public — the load balancer will be accessible from the Internet and will be able to proxy requests from the public subnet to cloud servers on the private subnet. If you will be hosting cloud servers on the same subnet, choose a network of /28 or larger, or make sure there is a free IP address for the load balancer port.
  10. Specify the IP address in the subnet, a free address that will be assigned to the balancer.

  11. Optional: Connect a public IP address. If there is no free public IP address available, create a new IP address. The private subnet in which you create the balancer must be prepared to connect a public IP address.

  12. Press Next.

2. Create a task force

  1. Open the Servers tab.

  2. Optional: To change the name of the target group, click , enter a name, and click .

  3. Select the traffic assignment protocol that the balancer uses to send traffic to the target group. The following combinations of protocols are available for accepting traffic on the balancer and assigning traffic to the target group:

    • TCP-TCP is classic L4 balancing;
    • TCP-PROXY — client information is not lost and is transmitted in a separate connection header;
    • UDP-UDP — The UDP protocol is faster than TCP, but less reliable;
    • HTTP-HTTP — L7-balancing;
    • HTTPS-HTTP — L7 balancing with encryption and SSL certificate termination on the balancer.
  4. A default port will be automatically selected for the selected protocol — change it if necessary. The port value will be common to all servers in the group.

  5. Mark the servers to be added to the target group.

  6. Specify settings for each marked server:

    6.1 Select the IP address.

    6.2 Optional: change the port.

    6.3 Specify the server weight — this is a proportional measure, denotes the share of requests that the server handles. If the weights are the same, the servers serve the same number of requests. If, for example, there is one server in a group with a weight of "2" and two servers with a weight of "1", the first server will receive 50% of all requests and the other two will each receive 25%. The maximum weight value is 256.

    6.4 Optional: To direct traffic to a server only when other servers in the group are unavailable, check the Backup checkbox.

  7. Open the Algorithm tab.

  8. Select either Round Robin or Least connections as the query distribution algorithm.

  9. Optional: To enable the Sticky Sessions method, check the Sticky sessions checkbox and select a session ID. For APP-cookie ID, enter a cookie name.

  10. Open the Availability Checks tab.

  11. Select the type of availability check. Once the group is created, you cannot change the check type.

  12. If you selected the HTTP validation type, specify the request parameters — method, path, and expected response codes.

  13. Specify the check interval — the interval in seconds at which the balancer sends check requests to servers.

  14. Specify the connection timeout — the maximum time to wait for a response in seconds, must be less than the interval between checks.

  15. Specify the success threshold — the number of successful accesses in a row, after which the server is put into a working state.

  16. Specify the failure threshold — the number of unsuccessful requests in a row, after which the server is suspended.

  17. Optional: To add another target group, click Add Target Group and customize it.

  18. Press Next.

3. Create rules and HTTP policies

  1. Select the protocol for receiving traffic on the load balancer — TCP, UDP, HTTP, or HTTPS. The Prometheus option is also available for configuring load balancer monitoring.
  1. For the selected protocol, the default port on which the balancer will listen to traffic will be automatically selected — change it if necessary.

  2. Optional: Enter the allowed CIDR — IP addresses from which the balancer will accept traffic with the selected protocol and port. You can enter a subnet in CIDR format or a single IP address with a /32 mask. If you leave the field blank, the balancer will accept traffic from any IP addresses. You can specify the allowed IP addresses in the rule after the balancer is created.

    If this field is absent, port security is disabled on the balancer's network.

  3. Select a target group. Groups are available to which you can balance traffic using the selected traffic reception protocol.

  4. Optional: expand the Advanced Rule Settings block and specify connection settings:

    • for incoming requests to the balancer — specify the connection timeout and maximum connections;
    • for requests from the balancer to servers — specify the connection timeout, inactivity timeout and TCP packet waiting timeout.
  5. Optional: To add another rule, click Add Rule and repeat steps 1-5. The number of rules is unlimited.

  6. Check the total cost of the balancer.

  7. Click Create Balancer.