当前位置:网站首页>Implementation principle of global load balancing

Implementation principle of global load balancing

2022-06-21 21:23:00 51CTO


author : Tianyi cloud   Dengjie

Key words of this article : Global load balancing 、DNS、 Health detection

introduction :

Global load balancing refers to the load balancing among server clusters placed in different geographical locations . Server load balancing refers to load balancing the local server group . Global load balancing is mainly used to have its own server sites in multiple regions , So that global users only have one IP Address or domain name can access the nearest server , To get the fastest access speed . Global load balancing can balance the load among server clusters placed in different geographical locations . It can help enterprise services achieve high concurrent load sharing in different geographical locations 、 The user accesses the nearest access 、 Automatic isolation of service failure or remote disaster recovery .



One 、 What does global load balancing achieve ?

 Implementation principle of global load balancing _ The server

1、 Global load balancing is based on DNS Implementation of a set of load balancing system , The system has the basic domain name resolution function , Through the domain name requested by the user , Response to the... After the load policy calculation ip Address to client .

2、 Client access www.test.com The website of , Browser first through DNS Inquire about , Convert domain name to IP Address , And then through IP Address to access the actual web server , Complete the web page request .


Two 、 How to add a domain name DNS Request access to the global load balancing service

Usually DNS The authoritative server can direct the domain name request to another server in two ways DNS Authoritative server .

1、 The first way is through NS Record how the subdomain is authorized , Authorize the entire subdomain name to another DNS Authoritative server , Setting up www.test.com Of ns Record as ns1.gslb.ctyun.cn and ns2.gslb.ctyun.cn.

2、 The second way is through CNAME The way of recording , Set up www.test.com Of CNAME The record points to xxxxx.gslb.ctyun.cn( After the global load balancing product service is enabled , The system automatically assigns addresses ).



3、 ... and 、 The overall schematic diagram of the global load balancing business layer

 Implementation principle of global load balancing _ Load balancing _02


1、 Load balancing component

Global load balancing mainly consists of Auth-DNS Components 、GSLB Components 、monitor Components . Their respective functions are as follows :

Auth-DNS modular : be based on DNS A simplified version of the protocol implementation authority DNS The server , Only available A Record and AAAA Records of the DNS Request service .

GSLB modular : According to various load balancing policies created by users 、pool Pool load balancing algorithm 、 and IP Health status choose the right IP Address returned to user .

monitor modular : Probe pool In the pool ip Address health status .

2、 domain name DNS Request flow

a) Auth-DNS Component receives user requests

When the end user accesses the domain name through the browser , Local DNS The domain name resolution request will be sent to DNS Recursive server ( Such as 114.114.114.114), And then pass by DNS Recursive server iteration request , Finally, the domain name resolution request will be sent to the global load balancing service Auth-DNS Components ;


Auth-DNS Component reception DNS After the request , according to RFC1035、RFC2671、RFC7871 And so on DNS Protocol parsing . obtain DNS Source in request IP Address 、 Domain name and request type , In getting the source IP Address time , priority of use edns-client-subnet The user carried by the protocol is real IP Address .


b) GSLB Select the appropriate component IP Address response to user request

First step : By domain name , Find the user subscribed GSLB example .


The second step : according to GSLB The instance can query all associated access policies , The main function of access strategy is to combine the regional information or operator information with pool Pool Association . According to the user's reality IP Address , You can select a qualified access policy policy. And start trying to use all the matching access policies policy The associated pool The address pool responds to user requests .


Access policies in the system policy With priority attribute , Give priority to using high priority access policies to respond to user requests , The priority is from high to low :

telecom - southwest - sichuan > China - southwest - sichuan > telecom - southwest > China - southwest > telecom > China > overall situation


The third step : The resource pool can select specific load balancing algorithm types , Including polling 、 Weighted polling 、 Hash 、 Random 、 priority . Try to use specific load balancing algorithm in pool Select a healthy address in the address pool IP Address response user DNS request .


If pool All in the pool IP The addresses are all unhealthy , The system will try to select pool The fallback pool that the address pool points to ( the other one pool Address pool ) Conduct IP Address selection , The selection logic is consistent with step 3 . If you still can't find the right one IP Address , The system will try to use other access policies to restart from the second part IP Address .


Step four : Will choose IP Address result , adopt Auth-DNS Components , encapsulation DNS Response message body , The reply DNS request .


c) monitor Component pair pool In the pool IP Address for health detection

monitor Component support icmp、udp、tcp、http、https Health detection methods , Each health test has its own user-defined parameters , Such as interval time 、 Timeout and other information .monitor The component will detect information according to the user configuration , Yes pool In pool IP Address for health testing , And the test results are returned to in real time GSLB Components .


monitor The component deploys detection services in multiple locations across the country , Each probe node operates independently , Have their own detection data ; The system will collect the health detection results of all detection nodes , The current version adopts the majority rule IP Is the address healthy , When think IP The number of nodes with healthy addresses is greater than that of IP Address the number of nodes that are not healthy , take IP The address is set to healthy status . Otherwise, it is set to non healthy .


Four 、 summary

Global load balancing is mainly based on DNS technology , While providing domain name resolution services , Add the source accessed by the client IP Select the nearest server for the address IP The ability of an address to respond to requests . And the global load balancing system provides user resource pool IP Address health detection function , Can be right IP Address for health detection in various ways , For abnormal IP Address in

原网站

版权声明
本文为[51CTO]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211836365958.html