There are several ways to load balance:
one, based on the client way:
Each client program has a certain knowledge of the server cluster, which in turn sends requests to different servers in a load-balanced manner. This approach is primitive, and now some older systems are still using this approach, and the client simply uses polling to achieve load balancing. This way of reliability, maintainability is very low, aggravating the difficulty of client development. The structure diagram is as follows:
second, DNS-based (DNS server)
A. Resolve the domain name to a different real Server B based on the client IP domain. For the same region of the real server, using Round-robin to turn the domain name to different real server DNS to do load balancing is simple and convenient, but the DNS cache time is long, if there is a problem, update the DNS information to wait for a few minutes or even 10 minutes of the client, the reliability is not high, The load balancing algorithm is not flexible enough.
PS: Every time the South customer asks DNS to be informed of the different South server IP, the same for northern users
Third, HTTP redirection (server side)
This is a method of load balancing determined by the server, which redirects the user's request to another server based on its own load and the IP region of the user, using HTTP 302.
Iv. third-party based applications
A DNS-like approach, or DNS load balancing, is an implementation of this approach. This approach requires a third-party application that acts as a load-balanced consultant for the entire system, the server cluster synchronizes its own state to the third-party application, and the client asks the third-party app before making the request and requests it in response to a third-party application. This approach is highly customizable, but both the server and the client need to add custom client live APIs. The structure diagram is as follows:
Five, based on the data link layer
This is a very low level of load balancing, generally implemented in the network equipment hardware. such as switches or routes, the load of each port is counted for proper forwarding.
six, based on the transport layer
There is one or several high-stability load-balancing servers in front of the server cluster, all requests reach the Load Balancer server first, and the Load Balancer server uses Round-robin and so on to forward the request to the real server. There are three kinds of IP load Balancing technologies: Vs/nat, VS/DR, Vs/tun.
1) Vs/nat (Virtual Server via network address translation): Translation) converts the internal address to an external address available on the internets.
2) VSDR (virtual server via direct Routing): Implements a virtualized server through direct routing. As with the Vs/tun method, VS/DR takes advantage of the asymmetric features of most internet services, where the load scheduler is only responsible for scheduling requests, and the server directly returns the response to the customer, which can greatly increase the throughput of the entire cluster system.
3) Vs/tun (virtual server via IP tunneling): Through the IP tunnel to implement the virtualized server, the request packet package dynamically forwarded to the back-end server, the response message can be returned directly from the back-end server to the customer. Because the request message is short and the response message often contains a large amount of data, it can greatly reduce the pressure of the load balancer. All servers must support the "IP Tunneling" or "IP Encapsulation" protocol.
Vii. based on the application layer
Similar to the transport layer-based approach, but support the analysis of application layer data, load balancing algorithm more flexible than the transport layer, for a number of non-important small business, can be connected to the same IP.
Viii. Arithmetic-based
The operation of the load is separated into different modules, and distributed to different cluster nodes to compute to increase the computation speed. such as Hadoop.
Each of these is a single point, and in real-world projects, it is often a mix of several technologies to achieve overall load balancing.
Front-end capability model-load balancing in various ways