Load balancing

Overview

Load balancing allows you to distribute traffic between two or more of your servers. This is very useful for sites that receive a lot of traffic. On a load balancer, only Nginx is installed. There is no database server, nor PHP, nor Node JS.

Create a load balancer

To create a load balancer, you simply need to create a new server by selecting the server type to Load balancer. Once the server is created, you will be able to create sites on it. These sites are not actually sites but rather setups to other sites / servers.

note The site you create must have the same domain name as the site that is to be balanced.

Configure a site

As soon as you create a site on a load balancer, you can link it to other servers. These servers must be on the same private network, that is, on the same server provider. On these same servers, you must also have created a site with the same domain name.

You can add as many servers as necessary and you must configure the port (80 default) that is configured on each of these servers. Then there are some options that we can see in detail.

Balancing method

Boxydev Cloud configures the Load Balancer server with Nginx. So we made the balancing method configurable. You can therefore choose from several methods :

  • Round Robin : Requests are distributed evenly across servers, taking into account the configured weight.
  • Least Connections : Requests are sent to the server with the least active connections, taking into account the configured weight.
  • IP Hash : The server where the requests are sent is determined by the client's IP address. This ensures that an IP address arrives at the same server.

Server weight

The weight of the server is configurable. Each server has a weight, which makes it possible to give importance to the server to receive more traffic. For example, you have two servers with a weight of 5 and 1. The first server will receive 5 out of 6 requests made to the Load Balancer.

Save and pause

You can mark a server with backup or down. The option backup allows you to specify that a server will only be available if no other is. The option down will pause the server and it will therefore no longer receive any requests.

SSL certificates

When you manage your application or your site with a load balancer, the SSL certificate must be configured on the load balancer. The servers are not directly accessibles so you don't have to configure a certificate on each server.

Also, don't forget to configure trusted proxies on Laravel or Symfony.