Getting started with Network Load Balancer
Network load balancers evenly distribute traffic evenly across cloud resources and monitor their health status. This enhances the availability and fault tolerance of your apps and cloud network infrastructure.
Create a network load balancer with a listener, attach a target group, and set up health checks using Network Load Balancer.
Getting started
- Log in to the management console
or sign up. If not signed up yet, navigate to the management console and follow the on-screen instructions. - On the Yandex Cloud Billing
page, make sure you have a linked billing account with theACTIVEorTRIAL_ACTIVEstatus. If you do not have a billing account yet, create one. - If you do not have a folder yet, create one.
- Create multiple VMs in advance to include them in the target group attached to your network load balancer. For testing, consider using low-cost preemptible VMs.
Create a target group
A target group consists of cloud resources that receive traffic from the network load balancer.
To create a target group:
- In the management console
, select the folder where you want to create a target group. - Navigate
to Network Load Balancer. - In the left-hand panel, select
Target groups. - Click Create a target group.
- Enter
test-target-groupas the target group name. - Select the VMs to add to the target group.
- Click Create.
Create a network load balancer
When creating a network load balancer, you need to set up a listener to handle incoming traffic and configure health checks for the targets in the attached target group.
To create a network load balancer:
- In the management console
, select the folder where you need to create a load balancer. - Navigate
to Network Load Balancer. - Click Create a network load balancer.
- Name the load balancer, e.g.,
test-load-balancer. - Select the load balancer's Type:
External. -
In the Public address field, select an IP address assignment method:
Auto: Assign a random IP address from the Yandex Cloud IP address pool. In this case, you can enable DDoS protection using the option below.List: To select a public IP address from the list of previously reserved static addresses. For more information, see Converting a dynamic public IP address to static.
-
Under Listeners, add a listener:
- Click Add listener.
-
In the window that opens, specify these listener settings:
-
Name.
-
Protocol:
TCPorUDP.Note
By default, the listener uses TCP. To use UDP, contact technical support
. -
Port where the listener will listen for incoming traffic. The possible values range from
1to32767. -
Target port to which the load balancer will redirect traffic. The possible values range from
1to32767.
-
- Click Add.
- Under Target groups, select the previously created target group.
-
Optionally, under Health check, click Configure. In the window that opens, specify the resource health check settings:
-
Name. The naming requirements are as follows:
- Length: between 3 and 63 characters.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Type:
HTTP,TCP,HTTP/2,HTTPS, orGRPC. -
Path: Specify a URL for health checks (for the
HTTP,HTTP/2,HTTPS, andGRPCtypes). -
Host: Specify a host (for the
HTTP/2,HTTPS, andGRPCtypes). -
Port for health checks. The possible values range from
1to32767. -
Timeout in sec: Response timeout in seconds. The possible values range from
1to60. The interval must be at least 1 second longer than the response timeout. -
Interval in sec: Health check interval in seconds. The possible values range from
1to60. -
Healthy threshold: Number of successful checks required to consider a VM instance ready to receive traffic.
-
Unhealthy threshold: Number of failed checks before traffic is no longer routed to the VM.
-
Click Apply.
-
- Click Create.
Check the resource status
To check the status of the network load balancer and targets in the attached target group:
- In the management console
, select the folder where you need to create a load balancer. - Navigate
to Network Load Balancer. - In the list, find the load balancer you created.
- Make sure the load balancer's status is
Active, which means it is ready to distribute traffic across the targets. - Click the load balancer name.
- Check Target groups. If the VMs are running and ready to receive traffic, their status must be
HEALTHY. - Open the Compute Cloud page and stop one of the VMs in the target group.
- Go back to the load balancer page and make sure the stopped VM's status is now
UNHEALTHY. This means the target in the group failed the health check and is not ready to receive traffic.
Delete the load balancer and the resources you created
If you no longer need the load balancer, delete it.
Then, delete the target group and VMs.
What's next
- Learn more about how network load balancers work here.
- See our best practices for deploying a network load balancer.