Getting started with Network Load Balancer
Network load balancers evenly distribute workload across cloud resources and monitor their status. This improves the availability and fault tolerance of your applications and cloud network infrastructure.
Create a network load balancer with a listener, attach a group of target resources, and set up health checks using Network Load Balancer.
Getting started
- Log in or sign up to the management console
. If not signed up yet, navigate to the management console and follow the on-screen instructions. - On the Billing
page, make sure you have a billing account linked and its status isACTIVE
orTRIAL_ACTIVE
. 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 the network load balancer. For testing, you can use inexpensive preemptible VMs.
Create a target group
A target group consists of cloud resources that the network load balancer distributes traffic across.
To create a target group:
- In the management console
, select the folder where you want to create a target group. - From the list of services, select Network Load Balancer.
- In the left-hand panel, select
Target groups. - Click Create a target group.
- Enter the target group name:
test-target-group
. - 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 create a listener that the load balancer will use to receive traffic. You also need to set up health checks for resources in the attached target group.
To create a network load balancer:
-
In the management console
, select the folder to create a load balancer in. -
From 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 addresses. For more information, see Converting a dynamic public IP address to static.
-
Under Listeners, click Add listener.
-
In the window that opens, set the listener parameters:
- Name.
- Port in the range of
1
to32767
the load balancer will receive incoming traffic at. - Target port in the range of
1
to32767
the load balancer will send traffic to.
-
Click Add.
-
Under Target groups, click Add target group.
-
Select a target group or create a new one:
-
Click Create target group.
-
Enter the name of the target group. The naming requirements are as follows:
- It must be 2 to 63 characters long.
- It may 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.
-
-
(Optional) Under Health check, click Configure and in the window that opens:
-
Enter a name for the health check. The naming requirements are as follows:
- It must be 2 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- It must start with a letter and cannot end with a hyphen.
-
Select either
HTTP
orTCP
for the check type. -
If you chose HTTP, specify the URL to check in the Path field.
-
Specify a port number between
1
and32767
. -
Specify the response timeout in seconds.
-
Specify the interval, in seconds, for sending health check requests.
-
Set the performance threshold, meaning the number of successful checks required in order to consider the VM ready to receive traffic.
-
Specify the failure threshold, which is the number of failed checks after which no traffic will be routed to the VM.
-
Click Apply.
-
-
Click Create.
Perform resource health checks
To check the status of the network load balancer and resources in the attached target group:
- In the management console
, select the folder to create a load balancer in. - From the list of services, select Network Load Balancer.
- Locate the new load balancer in the list.
- Make sure the load balancer's status is
Active
, which means it is ready to transmit traffic to the target resources. - Click the name of the load balancer.
- Look at 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 that the target from the group failed the health check and is not ready to receive traffic.
Delete a load balancer and the resources created
If you no longer need a load balancer, delete it.
Then delete the target group and VMs.
What's next
- Learn more about how network load balancers work.
- See our recommendations on deploying a network load balancer.