×
Community Blog What is Server Load Balancer and How It Works

What is Server Load Balancer and How It Works

Many people may wonder what Server Load Balancer is and how Server Load Balancer works, and what are the benefits of using Server Load Balancer.

Server Load Balancer Definition

Server Load Balancer or Server Load Balancing (SLB) is a service that distributes high traffic sites among several servers. Server Load Balancer intercept traffic for a website and reroutes that traffic to servers.

Server Load Balancer distributes inbound network traffic across multiple Elastic Compute Service (ECS) instances that act as backend servers based on forwarding rules. You can use Server Load Balancer to improve the responsiveness and availability of your applications.

What is Server Load Balancer?

Server Load Balancer Introduction Video

The Overview of Server Load Balancer

After you add ECS instances that reside in the same region to a Server Load Balancer instance, Server Load Balancer uses virtual IP addresses (VIPs) to virtualize these ECS instances into backend servers in a high-performance server pool that ensures high availability. Client requests are distributed to the ECS instances based on forwarding rules.

Server Load Balancer checks the health status of the ECS instances and automatically removes unhealthy ones from the server pool to eliminate single points of failure (SPOFs). This enhances the resilience of your applications. You can also use Server Load Balancer to defend your applications against distributed denial of service (DDoS) attacks.

The Components of Server Load Balancer

Server Load Balancer consists of three components:

  • Server Load Balancer instances
    A Server Load Balancer instance is a key load-balancing component in SLB. It receives traffic and distributes traffic to backend servers. To get started with SLB, you must create an SLB instance and add at least one listener and two ECS instances to the SLB instance.
  • Listeners
    A listener checks for connection requests from clients forward requests to backend servers and performs health checks on backend servers.
  • Backend servers
    ECS instances are used as backend servers in Server Load Balancer to receive and process distributed requests. ECS instances can be added to the default server group of a Server Load Balancer instance. You can also add multiple ECS servers to VServer groups or primary/secondary server groups after the corresponding groups are created.

Server_Load_Balancer_Definition

The Benefits of Server Load Balancer

  • Strong scalability
    You can increase or decrease the number of backend servers to adjust the load balancing capacity for your applications.
  • Low costs
    Server Load Balancer can save 60% of load balancing costs compared with using traditional hardware solutions.
  • Outstanding security
    You can use Server Load Balancer with Alibaba Cloud Security to defend your applications against 5 Gbit/s distributed denial of service (DDoS) attacks.
  • High concurrency
    A Server Load Balancer cluster supports hundreds of millions of concurrent connections, and a single Server Load Balancer instance supports tens of millions of concurrent connections.

How Does Server Load Balancer Work?

High availability of the Server Load Balancer architecture

Server Load Balancer instances are deployed in clusters to synchronize sessions and protect backend servers from SPOFs, improving redundancy, and ensuring service stability. Layer-4 Server Load Balancer uses the open-source Linux Virtual Server (LVS) and Keepalived software to balance loads, whereas Layer-7 SLB uses Tengine. Tengine, a web server project launched by Taobao, is based on NGINX and adds advanced features dedicated to high-traffic websites.

Requests from the Internet reach an LVS cluster along Equal-Cost Multi-Path (ECMP) routes. In the LVS cluster, each machine uses multicast packets to synchronize sessions with the other machines. At the same time, the LVS cluster performs health checks on the Tengine cluster and removes unhealthy machines from the Tengine cluster to ensure the availability of the Layer-7 Server Load Balancer.

Server Load Balancer Best practice:
You can use session synchronization to prevent persistent connections from being affected by server failures within a cluster. However, for short-lived connections or if the session synchronization rule is not triggered by the connection (the three-way handshake is not completed), server failures in the cluster may still affect user requests. To prevent session interruptions caused by server failures within the cluster, you can add a retry mechanism to the service logic to reduce the impact on user access.

The high-availability solution with one Server Load Balancer instance

To provide more stable and reliable load balancing services, you can deploy Server Load Balancer instances across multiple zones in most regions to achieve cross-data-center disaster recovery. Specifically, you can deploy a Server Load Balancer instance in two zones within the same region whereby one zone acts as the primary zone and the other acts as the secondary zone. If the primary zone suffers an outage, failover is triggered to redirect requests to the servers in the secondary zone within approximately 30 seconds. After the primary zone is restored, traffic will be automatically switched back to the servers in the primary zone.

Server Load Balancer Best practice:
We recommend that you create Server Load Balancer instances in regions that support primary/secondary deployment for zone-disaster recovery.
You can choose the primary zone for your Server Load Balancer instance based on the distribution of ECS instances. That is, select the zone where most of the ECS instances are located as the primary zone for minimized latency.
However, we recommend that you do not deploy all ECS instances in the primary zone. When you develop a failover solution, you must deploy several ECS instances in the secondary zone to ensure that requests can still be distributed to backend servers in the secondary zone for processing when the primary zone experiences downtime.

Server_Load_Balancer_instance

The high-availability solution with multiple Server Load Balancer instances

In the context of one Server Load Balancer instance, traffic distribution for your applications can still be compromised by network attacks or invalid Server Load Balancer configurations, because the failover between the primary zone and the secondary zone is not triggered. As a result, the load-balancing performance is impacted. To avoid this situation, you can create multiple Server Load Balancer instances to form a global load-balancing solution and achieve cross-region backup and disaster recovery. Also, you can use the instances with DNS to schedule requests so as to ensure service continuity.

Server Load Balancer Best practice:
You can deploy Server Load Balancer instances and ECS instances in multiple zones within the same region or across different regions, and then use DNS to schedule requests.

multiple_Server_Load_Balancer_instances

The Architecture of Server Load Balancer

Server Load Balancer instances are deployed in clusters to synchronize sessions and protect backend servers from SPOFs, improving redundancy, and ensuring service stability. Server Load Balancer supports Layer-4 load balancing of Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) traffic and Layer-7 load balancing of HTTP and HTTPS traffic.

Server Load Balancer forwards client requests to backend servers by using Server Load Balancer clusters and receives responses from backend servers over internal networks.

Server Load Balancer Design

Alibaba Cloud provides Layer-4 (TCP and UDP) and Layer-7 (HTTP and HTTPS) load balancing.

  • Layer-4 Server Load Balancer combines the open-source Linux Virtual Server (LVS) with Keepalived to balance loads and implements customized optimizations to meet cloud computing requirements.
  • Layer-7 Server Load Balancer uses Tengine to balance loads. Tengine is a web server project launched by Taobao. Based on NGINX, Tengine has a wide range of advanced features optimized for high-traffic websites.

Server_Load_Balancer_Design_1

Layer-4 Server Load Balancer runs in a cluster of LVS machines for higher availability, stability, and scalability of load balancing in abnormal cases.

Server_Load_Balancer_Design_2

In an LVS cluster, each machine synchronizes sessions with other machines via multicast packets. As shown in the below figure, Session A is established on LVS1 and is synchronized to other LVS machines after the client transfers three data packets to the server. Solid lines indicate the current active connections, while dotted lines indicate that the session requests will be sent to other normally working machines if LVS1 fails or is being maintained. In this way, you can perform hot updates, machine maintenance, and cluster maintenance without affecting business applications.

Server_Load_Balancer_Design_3

The Scenarios of Server Load Balancer

Server Load Balancer (SLB) can be used to improve the availability and reliability of applications with high access traffic.

Balance loads of your applications

You can configure listening rules to distribute heavy traffic among ECS instances that are attached as backend servers to SLB instances. You can also use the session persistence feature to forward all of the requests from the same client to the same backend ECS instance to enhance access efficiency.

Scale your applications

You can extend the service capability of your applications by adding or removing backend ECS instances to suit your business needs. Server Load Balancer can be used for both web servers and application servers.

Eliminate single points of failure (SPOFs)

You can attach multiple ECS instances to a Server Load Balancer instance. When an ECS instance malfunctions, Server Load Balancer automatically isolates this ECS instance and distributes inbound requests to other healthy ECS instances, ensuring that your applications continue to run properly.

Implement zone-disaster recovery (multi-zone disaster recovery)

To provide more stable and reliable load balancing services, Alibaba Cloud allows you to deploy Server Load Balancer instances across multiple zones in most regions for disaster recovery. Specifically, you can deploy a Server Load Balancer instance in two zones within the same region. One zone is the primary zone, while the other zone is the secondary zone. If the primary zone fails or becomes unavailable, the Server Load Balancer instance will failover to the secondary zone in about 30 seconds. When the primary zone recovers, the Server Load Balancer instance will automatically switch back to the primary zone.

We recommend that you create a Server Load Balancer instance in a region that has multiple zones for zone-disaster recovery. We recommend that you plan the deployment of backend servers based on your business needs. In addition, we recommend that you add at least one backend server in each zone to achieve the highest load balancing efficiency.

As shown in the following figure, ECS instances in different zones are attached to a single Server Load Balancer instance. In normal cases, the Server Load Balancer instance distributes inbound traffic to ECS instances both in the primary zone (Zone A) and in the secondary zone (Zone B). If Zone A fails, the Server Load Balancer instance distributes inbound traffic only to Zone B. This deployment mode helps avoid service interruptions caused by zone-level failure and reduce latency.

Scenarios_of_Server_Load_Balancer_1

Assume that you deploy all ECS instances in the primary zone (Zone A) and no ECS instances in the secondary zone (Zone B) as shown in the following figure. If Zone A fails, your services will be interrupted because no ECS instances are available in Zone B. This deployment mode achieves low latency at the cost of high availability.

Scenarios_of_Server_Load_Balancer_2

Geo-disaster recovery

You can deploy Server Load Balancer instances in different regions and attach ECS instances of different zones within the same region to a Server Load Balancer instance. You can use DNS to resolve domain names to service addresses of Server Load Balancer instances in different regions for global load balancing purposes. When a region becomes unavailable, you can temporarily stop DNS resolution within that region without affecting user access.

Scenarios_of_Server_Load_Balancer_3

Related Service:

Server Load Balancer

Alibaba Cloud Server Load Balancer (SLB) distributes traffic among multiple instances to improve the service capabilities of your applications. You can use SLB to prevent a single point of failure (SPOFs) and improve the availability and the fault tolerance capability of your applications.

Related Blog:

Quick Guide to Load Balancing on Alibaba Cloud

This article is intended for sharing my experience of what I have learned about Alibaba Cloud Server Load Balancer (SLB) from Alibaba Cloud Academy. Although this is not a new topic to me, I took the ACA course to get my fundamentals right as I believe it is very important. I've also learned a lot of new things, especially topics related to Alibaba Cloud-specific technologies. I gained a deeper understanding of how Alibaba Cloud can help my organization increase its profit by reducing operating costs.

Solving Server Reliability Problems with Server Load Balancer

A Server Load Balancer is a hardware or virtual software appliance that distributes the application workload across an array of servers, ensuring application availability, elastic scale-out of server resources, and supports health management of backend servers and application systems.

How Can a Server Load Balancer Help Your Website or Application?

Traditionally, we need a web server to provide and deliver services to our customers. Usually, we want to think if we can have a very powerful web server that can do anything we want, such as providing any services and serving as many customers as possible.

However, with only one web server, there are two major concerns. The first one is there is always limited to a server. If your business is booming, lots of new users are coming to visit your website so one day your website will definitely reach your capacity limit and will deliver a very unsatisfying experience to your users.

Also, if you only have one web server, a single point of failure may occur. For example, a power outage or network connection issues may happen to your servers. If your single server is down, your customers will be totally out of service, and you cannot provide your service anymore. This is the problem you may suffer when you have only one web server, even if it is very powerful.

0 0 0
Share on

Alibaba Clouder

2,599 posts | 764 followers

You may also like