Working Principle and Implementation of Global Load Balancing
Simple Application Server
USD1.00 New User Coupon
* Only 3,000 coupons available.
* Each new user can only get one coupon(except users from distributors).
* The coupon is valid for 30 days from the date of receipt.
1. The role of global load balancing in the CDN system
The CDN system always hopes to use the device closest to the user to provide services to the user, so that multiple nodes need to be deployed in different locations across the network. The CDN global load balancing system GSLB is to solve the problem of mutual coordination between nodes and realize the large-scale service capability and high availability of the entire system.
GSLB is mainly to balance between multiple nodes, the result may directly end the load balancing process, or it may deliver user access to the next level of load balancing system
In a regional or local load balancing system, each service node only grasps the information of the service equipment in the node, while in the GSLB system, it is necessary to grasp the information in all nodes
2. GSLB implementation mechanism based on DNS resolution
First understand what DNS resolution is:
DNS record type and message format:
A record, Address. Describes the mapping relationship between domain names and IP addresses. For the same domain name, there can be multiple mapping records
NS records the Name Server. Domain name server records are used to specify which DNS server will resolve the domain name.
SOA records Start Of Authority. Record the authoritative domain name server that specifies the zone.
CNAME. Record the correspondence between aliases and domain names. This record allows multiple names to be mapped to the same computer
PTR record, Point Record. Records are used to describe the mapping relationship between IP addresses and domain names.
Several methods to implement GSLB based on DNS resolution:
The GSLB scheme based on DNS resolution actually deploys load balancing equipment in the DNS system. When a user makes a request, the IP address of the server is first requested through the DNS system. DNS-based GSLB makes intelligent decisions in the process of returning DNS results and returns the appropriate IP address to the user
1. Realize load balancing through CNAME
CNAME describes the alias of a domain name or host name. After the domain name server obtains the CNAME record, it will replace the searched domain name or host name with the alias in the record.
The implementation utilizes the alias mechanism and rotation training mechanism of DNS itself.
First define the GSLB host name as the alias of the authoritative DNS server of the domain name being queried, and then add multiple A records to the GSLB host name, corresponding to the IP addresses of multiple servers. In this way, the local DNS server will return multiple IP addresses to the client as the query result, and the order of these IP addresses is rotated
2. Load balancer as authoritative DNS server
The load balancer acts as an authoritative DNS server, so that GSLB will receive all DNS requests for this domain, so that it can perform intelligent DNS resolution according to some preset policies.
All requests go through GSLB, which will more or less affect DNS resolution.
3. Load balancer as a proxy DNS server
In this case, the load balancer is also registered as an authoritative DNS server for a domain name space and the real authoritative name server is deployed behind the load balancer. All requests will first reach the load balancer, and the load balancer will forward to the real authoritative DNS server, and then modify the response information returned by the authoritative DNS server to achieve load balancing.
Policy judgment conditions for load balancing
The "health" of the server. Health check, failure to pass the domain name resolution result
Geographical distance. Due to the limitation of the working principle of the DNS system itself, GSLB can only see the IP address of the user's local DNS server, but not the IP location of the user terminal
The session is maintained. It is necessary to ensure that the access of the same user is scheduled to the same server.
Response time. Optimize GSLB strategy by measuring the server's response time
IP address weight. The weight value determines the proportion of traffic allocated to an IP compared to other candidate IPs.
Session capability threshold. The GSLB controller can obtain the number of sessions currently available for each server and the maximum size of the session table. Servers that reach the threshold will not be selected
RTT Rount-Trip Time.
Other information, including the number of sessions currently available on the server, the minimum number of choices, rotation training, etc.
3. DNS-based GSLB application deployment method
Domain Group: According to the alias setting, the user selects the service pool and specific virtual server to provide services according to the alias.
Service Pool Pool: The logical group concept of multiple virtual servers that provide the same kind of business.
Virtual Server: A virtual device that directly provides services when a user visits a website. Its IP address is the address returned by the GSLB final analysis.
Region: The address range represented by the user's local DNS. The user can define the region by setting the local DNS address in the browser.
Strategy: GSLB routing control strategy.
Based on a specific user source IP address. A specific IP address is directed to a specific POP node.
IP address based on weight.
Based on weighted POP nodes. The corresponding level of POP node is virtual server.
Based on geographic location.
Based on POP node management priority.
Based on simple rotation.
Dynamic strategy
Based on the health status of the POP node.
Based on relative conversational ability. GSLB will periodically calculate the ratio of the current number of sessions to the maximum number of sessions, and then compare it with the maximum threshold. If the threshold is exceeded, the node is not the best selected node.
Based on absolute conversational ability. The ratio of relative sessions is not calculated, but the current number of sessions is directly compared with the maximum threshold.
Based on physical server binding.
Based on actively measured user access round trip time RTT.
User visit round trip time based on passive measurement.
Based on the number of new connections
Based on traffic. According to the POP node or virtual server how many bits of data throughput per second is completed.
Based on the number of POP node visits
4. GSLB based on application layer protocol redirection
work process:
The user first requests domain name resolution from the website's local DNS.
Since the website has made the domain name CNAME point to the CDN's GSLB domain name and IP in advance, the local DNS will return the IP address of the GSLB device to the user.
The user sends an HTTP GET request to the dynamic GSLB device, requesting a certain resource of the website.
GSLB equipment selects a suitable service unit for users based on comprehensive analysis of real-time information such as user IP, content distribution, equipment load, and link status.
The user sends a media access request to the CDN node according to the obtained IP address.
If this IP address is still a load balancing device, the device will select a specific device and return it to the user.
The user sends the request again according to the obtained IP address.
5. GSLB based on IP routing
First, configure two local load balancers with the same VIP address. For routers on the IP network, these are two different routes to the same IP address.
When the terminal sends a request, when passing through the router, it will choose which path to take according to the routing table and forward the data packet to the local load balancer.