In-depth understanding of load balancing principles and algorithms

1 Introduction

In the early days of the Internet, the network was not very developed, there were few Internet users, and the traffic was relatively small. The system architecture was mainly based on a single architecture. But today, with the development of the Internet, traffic requests can reach tens of billions, or even hundreds of billions, and a single server or instance can no longer meet the demand, which is why there is a cluster. Whether it is to achieve high availability or high performance, it is necessary to use multiple machines to expand service capabilities. No matter which server the user's request is connected to, the user's request can be processed in the same way.

On the other hand, how to build and schedule service clusters must be sufficiently transparent to the user side. Even if a thousand or ten thousand machines are behind the request to respond together, it is by no means a matter of concern to the user , users need to remember only one domain name address. Scheduling multiple machines at the rear to provide external services with a unified interface, the technical component that undertakes this responsibility is called  load balancing .

2. Concept

负载均衡,英文名称为Load Balance,其含义就是指将负载(工作任务或者网络请求)进行平衡,分摊到多个操作单元(服务器或者组件)上进行运行。目的是尽量将网络流量 平均 发送到多个服务器上,以保证整个业务系统的高可用。负载均衡构建在原有网络结构上,它提供了一种透明且廉价有效的方法,扩展服务器和网络设备的贷款、加强网络数据处理能力、增加吞吐量、提高网络的可用性和灵活性。

picture

load balancing

Load balancing mainly has the following functions:

  • High concurrency: By adopting a certain algorithm strategy, the traffic is sent to the server as evenly as possible, so as to improve the concurrent processing capability of the cluster.

  • Scalability: According to the size of the network traffic, increase or decrease the back-end server instance, controlled by the load balancing device, which makes the cluster scalable.

  • High availability: The load balancer monitors candidate instances through algorithms or other performance data. When the instance load is too high or abnormal, it reduces its traffic requests or directly skips the instance, and sends the request to other available instances, which makes the cluster highly efficient. available features.

  • Security protection: Some load balancers provide security protection. Such as: black and white list processing, firewall, etc.

3. Classification

3.1 Classification according to geographical scope

Load balancing is divided into local load balancing (Local Load Balance) and global load balancing (Global Load Balance, also called regional load balancing ) according to the geographical structure of its application .

3.1.1 Local load balancing

本地负载均衡是指对本地的服务器群做负载均衡。

Local load balancing is used for load balancing of server groups in the local area. Local load balancing does not need to spend a lot of money to purchase high-performance servers. It only needs to use existing equipment resources to effectively avoid the loss of data traffic caused by server single-point failure. Usually It is used to solve the problem of excessive data flow and heavy network load. At the same time, it has a variety of balancing strategies to distribute data traffic to each server in a reasonable and balanced manner. If you need to upgrade and expand the current server, you don't need to change the existing network structure or stop the existing service, you only need to simply add a new server to the service group.

3.1.2 Global load balancing

全局负载均衡是指对分别放置在不同的地理位置、有不同网络结构的服务器群间作负载均衡。

Global load balancing mainly solves the problem that global users only need a domain name or IP address to access the server closest to them to obtain the fastest access speed. It has its own server sites in multiple regions, and it is also applicable to those subsidiaries Large companies with widely distributed sites use the intranet to achieve the purpose of uniform and reasonable allocation of resources. Global load balancing has the following characteristics:

  • Improve server response speed, solve network congestion problems, and achieve high-quality network access effects;
  • It can provide users with completely transparent services from a long distance, and truly achieve independence from geographical location;
  • It can avoid various single-point failures, including single-point failures of data centers, servers, etc., and single-point failures caused by dedicated line faults.

Content delivery network  CDN (Content Delivery Network) uses global load balancing. Suppose we store pictures on a CDN server, and the CDN has servers deployed in Beijing and Hangzhou. So:

  • When a Tianjin user downloads a picture, the traffic request will be automatically forwarded to the CDN server in Beijing;

  • When a Jiangsu user downloads a picture, the traffic request will be forwarded to the server in Hangzhou;

3.2 Classification by Carrier Type

From the perspective of carriers that support load balancing, load balancing can be divided into two categories: hardware load balancing and software load balancing.

3.2.1 Hardware load balancing

The hardware load balancing solution is to directly install a load balancing device between the server and the external network. This kind of device is usually called a load balancer . Because the special device completes the special task and is independent of the operating system, the overall performance is greatly improved. Coupled with diversified load balancing strategies and intelligent traffic management, the best load balancing requirements can be achieved.

This kind of equipment has strong performance and powerful functions, but the price is very expensive. Generally, only rich companies will use this kind of equipment. Small and medium-sized companies generally cannot afford it, and the business volume is not so large. Using these equipment is also a waste.

There are currently two industry-leading hardware load balancers: F5 and A10.

Guess you like

Origin blog.csdn.net/my8688/article/details/132043959