Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

How to Deploy a Load Balancer

A load balancer distributes requests among multiple servers, so none gets overloaded and the service stays up even if one fails.

In this tutorial you create a load-balancing rule over a pool of at least two servers in the same subscription.

๐Ÿ‘ What you get

A load-balancing rule that publishes a service on a public IP and distributes traffic among the servers you choose.

How load balancing fits in

Traffic arrives at a public IP and port, and the balancer distributes it among the pool's servers according to an algorithm. For this to work, all the servers in the pool must serve the same thing: load balancing distributes the load, it does not synchronize content.

๐Ÿ“˜ It distributes load, it is not full high availability

Load balancing improves availability and absorbs spikes, but it does not make your service foolproof.

If one server in the pool serves something different from the others, the client will see inconsistent responses. Keep the same content and configuration on all of them.

Before you begin

  • Log in to the Plenit platform with a user who has administration permissions over the organization.

  • At least two servers deployed in the same subscription. You can create the rule before adding them and incorporate them later.

Step 1. Go to Load Balancers

  1. Enter the subscription of Servers from its card.

  2. Open the subsection Load Balancers from the left side menu.

{/* ๐Ÿ“ธ SCREENSHOT 1 ยท left menu with the Load Balancers subsection */}

Access to the Load Balancers subsection

Step 2. Create a new rule

If there are no rules yet, you will see the start screen to create one; if they already exist, you will see the list. Select the Network on which you are going to create the rule and click New rule.

{/* ๐Ÿ“ธ SCREENSHOT 2 ยท selecting the Network and the New rule button */}

Creation of a new load-balancing rule on a network

Step 3. Configure network, IP and ports

  1. Choose the network with Select network.

  2. Select one Public IP from those available for that network.

  3. Define the Protocol (TCP or UDP), the Public Port (through which requests from the Internet enter, for example 80 or 443) and the Private Port (to which they are forwarded internally).

  4. Click Next.

๐Ÿšง One port, one single use per network

Within the same network, a port can only be used once: there cannot be two rules for the same port in the same network space.

{/* ๐Ÿ“ธ SCREENSHOT 3 ยท Public IP, Protocol, Public Port and Private Port fields */}

Configuration of public IP, protocol and ports

Step 4. Define which networks will have access

Indicate from which IPs the published service can be accessed:

  • Any: access from any network. It is the least secure option.

  • Specify: access only from the IPs or ranges you indicate.

With Specify, enter the allowed IP or range (you can add several) and click Next.

{/* ๐Ÿ“ธ SCREENSHOT 4 ยท Specify option with the allowed IP or range */}

Definition of the networks with access to the published service

Step 5. Choose the algorithm and affinity

Select how requests are distributed among the pool's servers:

Algorithm
What it does
When it fits

Round Robin

Distributes in turns, in a circular manner

General case, equivalent servers

Least connections

Sends each request to the server with the fewest active connections

Requests of unequal duration

Source

Assigns according to the source IP

When the same client must always go to the same server

Then, decide whether you enable the affinity rules. Enable them if the application stores session state on the server itself and does not share it between machines; if you do, complete Table size (KB) and Expiration(s). Click Next.

๐Ÿ“˜ Affinity keeps the client on the same server

Without shared state between servers, blind distribution can cut off a user's session midway through browsing. Affinity prevents this by tying it to a server, at the cost of a slightly less even distribution.

{/* ๐Ÿ“ธ SCREENSHOT 5 ยท selecting the algorithm and the affinity option */}

Selection of the distribution algorithm and affinity

Step 6. Select the pool servers

Choose the machines that will respond to requests. Click each element that appears as Not selected and assign it the corresponding IP. A server that has been added correctly shows a check mark and the outline highlighted in Plenit's color. When you are done, click Create Rule.

{/* ๐Ÿ“ธ SCREENSHOT 6 ยท selecting the pool servers with the added check mark */}

Selection of the servers that make up the load balancer pool

Step 7. Verify that the rule has been created

During creation you will see a message like Servers: Creating Load Balancer ... and, when it finishes, another confirming that it was created successfully. The rule appears in the list, although you may need to refresh the screen.

To check that the service really responds, test the public endpoint from outside. On Linux or macOS:

On Windows, from PowerShell:

And on each server in the pool, confirm that the service is listening on the private port. On Linux:

On Windows:

If something doesn't fit

Symptom
Likely cause
What to do

Cannot create the rule because of the port

That port is already in use in the network

Use another public port or free the existing one

The public endpoint does not respond

No server in the pool is listening on the private port

Check with ss / netstat that the service is up

A user loses the session while browsing

Distribution without shared state

Enable affinity or share state between servers

Conclusion

With this, you have a service published behind a balancer that distributes traffic among several servers, which smooths out spikes and keeps the service running even if one machine fails. Load balancing truly performs when the pool is homogeneous and you choose the algorithm that fits your workload: that's when you stop distributing requests blindly and start distributing them with purpose.

Last updated

Was this helpful?