- Region selection
- Choosing a network for balancing
- Setting up listeners
- X-Forwarded-For for the listener
- Pool setup
A load balancer is a tool for sorting incoming requests among your virtual machines to improve the fault tolerance of your infrastructure.
Creating a load balancer
To create a load balancer, go to your project - > Networking - > Load Balancers - > Create Load Balancer.
Configuring the load balancer
In the pop-up window, configure the load balancer:
1. Region selection
Select the region for balancing. Please note that you can balance traffic only within a single data center
2. Choosing a network for balancing
f you want to use the private network for load balancing, enable the option "Use private network". Select the network and subnet to sort the traffic. For more information about configuring subnets, see the article “Networking”
3. Setting up listeners
To create a load balancer, you need to add one or more listeners.
A listener is a process that checks for connection requests, using the protocol and port that you configure.
In the drop-down window, specify the listener name, Protocol (we support TCP and HTTP), and port in the range from 1 to 65535.
We also support the option to add an X-Forwarded-For header to identify the origin of the IP address of the client connecting to the web server via the load balancer.
Click on the "Add listener" button.
4. Pool setup
After creating the listener, you need to configure the pool.
A pool is a list of virtual machines to which the listener will redirect incoming traffic.
Click on "Add pool" to start configuring.
41. Specify the pool name
4.2. Select the balancing algorithm:
Round robin — requests are distributed between servers within the cluster sequentially: the first request is sent to the first server, the second — to the second server, and so on in a circle.
Least Connection — new requests are sent to the server with the fewest current connections to clients.
Source IP — the IP address of the client is used to determine which server receives the request.
4.3. Select protocol. Currently, the balancer can only communicate with servers over the HTTP protocol.
4.4. If you need to route the requests for a particular session to the same machine that serviced the first request for that session, select "App Cookie" and fill in the "Cookie" field. A special module creates a cookie — which makes each browser unique — and then uses it to forward requests to the same server.
4.5. Add the virtual machines that will participate in the traffic distribution for the configured listener. For adding an instance, you must specify its port and weight in the distribution.
4.6. In the "Health check" section, select the Protocol for checking: TCP, Ping, HTTP.
For the HTTP Protocol, select the HTTP method and add the URL path.
Also for all protocols specify:
1. "Check interval (sec)" — time between sent requests
2. "Response time (sec)" — the time to wait for a response from the server
3. "Unhealthy Threshold" — the number of failed requests after which traffic will no longer be sent to the virtual machine
4. "Healthy Thresholds" — the number of successful requests after which the virtual machine will be considered ready to receive traffic.
Click Add listener.
5. Enter a name for the load balancer and click "Create Load Balancer"
Important: A separate public IP is allocated for a load balancer; the IP address cost is included in the cost of the service itself.
Managing the load balancer
The list of created balancers is located inside the project - > "Networking "- > "Load balancers"
Options with balancer
You can perform the following options with created balancer:
- Configuring the balancer (the “Overview” option)
- Rename (the “Edit” option)
To choose the option select the necessary option on the selector on the right from the balancer
Configuring the created balancer
Go to your project - > Networking - > Load balancers -> select the "Overview" option on the selector on the right from the chosen balancer.
In the drop-down window, you can edit existing listeners in the load balancer and also add new ones.
You can edit and delete listeners. Select the appropriate option on the selector on the right from the listener.
In the editor, you can:
- Change the checking algorithm
- Parameters of connected instances (including verification address, port, and weight)
- Enable and disable instances from the load balancing pool
- Change the parameters in the "Health Check" section
Load Balancer statuses
|Status (UI)||Status (API)||Value|
The balancer is working.
All virtual machines in the pool accept requests
|Unhealthy||Draining||A virtual machine from the pool does not accept new requests|
|Degraded||One or more balancer components have an Error status|
The balancer doesn't work.
Virtual machines do not pass status check requests.
All virtual machines in the pool have the Error status