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 you are not signed up yet, navigate to the management console and follow the instructions. - On the Billing
page, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not yet have a billing account, 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. - In the list of services, select Network Load Balancer.
- In the left-hand panel, select
Target groups. - Click Create target group.
- Enter a name for the target group:
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. -
In the list of services, select Network Load Balancer.
-
Click Create a network load balancer.
-
Enter a name for the load balancer, such as
test-load-balancer
. -
In the Public address field, choose a method for assigning an IP address:
- Auto: Assign a random IP address from the Yandex Cloud IP pool.
- List: 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
that the load balancer will receive incoming traffic on. - Target port in the range of
1
to32767
that 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:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be 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 the health check name. The naming requirements are as follows:
- The name must be from 3 to 63 characters long.
- It may contain lowercase Latin letters, numbers, and hyphens.
- The first character must be a letter and the last character cannot be a hyphen.
-
Select the check type:
HTTP
orTCP
. -
If you chose HTTP, specify the URL to check in the Path field.
-
Enter a port number ranging from
1
to32767
. -
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. - In the list of services, select Network Load Balancer.
- Locate the created load balancer in the list.
- Make sure the load balancer 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 that the stopped VM status is
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.