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. - In the list of services, select 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. -
In the list of services, select Network Load Balancer.
-
Click Create a network load balancer.
-
Name the load balancer, e.g.,
test-load-balancer. -
In the Public address field, select an IP address assignment method:
- Auto: To assign a random IP address from the Yandex Cloud IP address pool.
- List: To select a public IP address from the list of previously reserved static IP addresses. For more information, see Converting a dynamic public IP address to static.
-
Under Listeners, click Add listener.
-
In the window that opens, specify these listener settings:
- Name.
- Port (ranging from
1to32767) on which the load balancer will listen to incoming traffic. - Target port (ranging from
1to32767) to which the load balancer will direct traffic.
-
Click Add.
-
Under Target groups, click Add target group.
-
Select a target group or create a new one:
-
Click Create target group.
-
Enter a name for the target group. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Select the VMs to add to the target group.
-
Click Create.
-
-
Optionally, under Health check, click Configure and in the window that opens:
-
Enter a name for the health check. Follow these naming requirements:
- It must be from 2 to 63 characters long.
- It can only contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Select either
HTTPorTCPfor the check type. -
If you selected HTTP, specify the URL for health checks in the Path field.
-
Specify a port number between
1and32767. -
Specify the response timeout in seconds.
-
Specify the interval in seconds for sending health check requests.
-
Specify the healthy threshold, i.e., the number of successful checks required to consider the VM ready to receive traffic.
-
Specify the unhealthy threshold, i.e., the 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 with the load balancer. - In the list of services, select 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.