Linux-based Load Balancing Technology

Source: Internet
Author: User
Tags domain name server
Linux-based Server Load balancer technology-Linux Enterprise Application-Linux server application information. The following is a detailed description. Preface
At present, the development of business volume in Enterprise Networks, campus networks, and wide area networks, such as the Internet, exceeds the most optimistic estimates in the past. The Internet boom is surging and new applications are emerging one after another, even if the network is built according to the optimal configuration at that time, it will soon feel overwhelmed. Especially for the core parts of each network, the large data traffic and computing strength make it impossible for a single device to undertake, however, how can we achieve reasonable service volume allocation among multiple network devices with the same function, so that it does not mean that one device is too busy, but other devices are not able to make full use of the processing capabilities, as a result, the Server Load balancer mechanism came into being.
  
Based on the existing network structure, Server Load balancer provides a cheap and effective method to expand server bandwidth and increase throughput, enhance network data processing capabilities, and improve network flexibility and availability. It mainly implements the following tasks: solving network congestion problems, providing nearby services to achieve geographic location independence, providing users with better access quality, and improving server response speed; this improves the utilization efficiency of servers and other resources, and avoids spof in key parts of the network.
  
Definition
In fact, Server Load balancer is not a traditional "Server Load balancer". Generally, Server Load balancer only distributes loads that may be congested in one place to multiple places for sharing. It may be better understood to call it "Load Balancing. To put it bluntly, the role of Server Load balancer in the network is like the rotation duty system, which assigns tasks to everyone to complete, so as to avoid exhausting a person. However, in this sense, the balance is generally static, that is, the pre-determined "rotation" strategy.
  
Different from the rotation duty system, Dynamic Load Balancing uses some tools to analyze data packets in real time, master the data traffic conditions in the network, and allocate tasks reasonably. The structure is divided into local Server Load balancer and regional Server Load balancer (Global Server Load balancer, the latter type refers to load balancing between different geographic locations and different networks and Server clusters.
  
In the server cluster, each service node runs an independent copy of a required server program, such as a Web, FTP, Telnet, or e-mail server program. For some services (such as those running on Web servers), a copy of the program runs on all hosts in the cluster, network Load Balancing distributes workloads among these hosts. For other services (such as e-mail), only one host processes the workload. For these services, network load balancing allows the network traffic to flow to one host, when the host fails, the communication volume is moved to another host.
  
Structure of Server Load balancer Technology
Based on the existing network structure, Server Load balancer provides a cheap and effective method to expand server bandwidth and increase throughput, enhance network data processing capabilities, and improve network flexibility and availability. It mainly performs the following tasks:
  
Solves network congestion and provides nearby services to achieve location independence.
Providing users with better access quality
Increase Server Response Speed
Improves utilization efficiency of servers and other resources
Prevents single point of failure in key parts of the network
  
In a broad sense, Server Load balancer can be configured with dedicated gateways and Server Load balancer instances, or through some specialized software and protocols. SLB applications on a network are analyzed based on network bottlenecks at different levels. Start from the vertical Analysis of the client application, refer to the OSI layered model, we divide the implementation of Server Load balancer technology into Client Server Load balancer technology, application server technology, high-level protocol exchange, network access protocol exchange, and other methods.
  
Layer of Server Load balancer
Client-Based Load Balancing
  
This mode refers to the running of a specific program on the client of the network. The program periodically or irregularly collects the running parameters of the server group: CPU usage, disk IO, memory, and other dynamic information, then, based on a certain selection policy, find the best server that can provide services and send local application requests to it. If the load information collection program finds that the server is invalid, find another alternative server as the service option. The entire process is completely transparent to applications, and all work is processed at runtime. Therefore, this is also a dynamic load balancing technology.
  
However, this technology is universal. This special collection program must be installed on each client. To ensure transparent operation at the application layer, you must modify each application by dynamically linking the library or embedding the program, the client access request can be first sent to the server through the collection program to redirect the process. Code re-development is almost required for each application, and the workload is heavy.
  
Therefore, this technology is only used in special application scenarios. For example, when executing some proprietary tasks, it requires distributed computing capabilities and does not have many requirements for application development. In addition, the JAVA architecture model is often used to achieve distributed load balancing. Because java applications are based on virtual machines, an intermediate layer can be designed between the application layer and virtual machines, handle the work of Server Load balancer.
  
Server Load balancer technology for application servers
  
If the server Load balancer layer of the client is transplanted to an intermediate platform to form a three-tier structure, the client application does not need to be modified, transparently balance requests to the corresponding service nodes through the middle layer application server. A common implementation method is reverse proxy technology. The reverse proxy server can evenly forward requests to multiple servers, or directly return cached data to the client. This acceleration mode can improve the access speed of static webpages to a certain extent, to achieve the purpose of load balancing.
  
The advantage of using reverse proxy is that it can combine Server Load balancer with the high-speed cache technology of the proxy server to provide beneficial performance. However, it also has some problems. First, it is necessary to develop a reverse proxy server for each service. This is not an easy task.
  
Although the reverse proxy server itself can achieve high efficiency, for each proxy, the proxy server must maintain two connections, one external connection and one internal connection, therefore, the load on the proxy server is very large for extremely high connection requests. The reverse proxy can execute the load balancing policy optimized for the application protocol, and only access the idle internal server at a time to provide services. However, as the number of concurrent connections increases, the load on the proxy server itself becomes very large, and the reverse proxy server itself becomes a service bottleneck.
  
Load Balancing Based on Domain Name System
  
The scalable Web of NCSA was the first web system to use dynamic DNS round robin technology. Configure the same name for multiple addresses in DNS. Therefore, the client that queries this name will obtain one of the addresses, so that different customers can access different servers and achieve load balancing. This technology has been used in many well-known web sites, including early yahoo sites and 163. Dynamic DNS round robin is easy to implement without complicated configuration and management. It is widely used because it generally supports running unix-like systems such as bind8.2 and later.
  
DNS load balancing is a simple and effective method, but there are many problems.
  
First, the Domain Name Server cannot know whether the service node is valid. if the service node fails, the remainder system will still resolve the domain name to the node, resulting in invalid user access.
  
Second, because of the TTL (Time to LIVE) mark of the DNS data refresh Time, once the TTL is exceeded, other DNS servers need to interact with the server to obtain the address data again, you may obtain different IP addresses. Therefore, in order to allow random address allocation, TTL should be kept as short as possible. DNS servers in different places can update the corresponding address to obtain the address randomly. However, setting TTL too short will increase DNS traffic and cause additional network problems.
  
Finally, it cannot distinguish between servers, nor reflect the current running status of servers. When using DNS Server Load balancer, you must ensure that different customers' computers can obtain different addresses evenly. For example, user A may only browse several webpages, while user B may download A lot. Because the domain name system does not have an appropriate load policy, it is just A simple round-robin balancing, it is easy to send user A's requests to sites with low loads, while B's requests to sites with heavy loads. Therefore, in terms of dynamic balancing, the dynamic DNS round-robin effect is not ideal.
  
High-level protocol content exchange technology
  
In addition to the above load balancing methods, there are also technologies supporting load balancing capabilities within the Protocol, that is, URL switching or layer-7 switching, which provides a high-level control mode for access traffic. The Web content exchange technology checks all HTTP headers and executes load balancing decisions based on information in the headers. For example, you can determine how to provide services for personal homepage, image data, and other content based on the information. Common examples include HTTP redirection capabilities.
  
HTTP runs on the top layer of the TCP connection. The client directly connects to the server through the TCP Service with a constant port number 80, and then sends an HTTP request to the server through the TCP connection. Protocol exchange controls the load based on the content policy, instead of the TCP port number, so it does not cause access traffic to be stranded.
  
The server Load balancer device must allocate incoming requests to multiple servers. Therefore, the Server Load balancer device can only establish a TCP connection and determine how to balance the load after the HTTP request passes. When a website hits hundreds or even thousands of times per second, the analysis of TCP connections, HTTP header information, and process latency have become very important, we need to do everything possible to improve the performance of these parts.
  
There is a lot of useful information for load balancing in HTTP requests and headers. We can get the URL and webpage requested by the client from this information. With this information, the Server Load balancer device can direct all image requests to an image server, or call the CGI program based on the URL's database query content to direct the request to a dedicated high-performance database server.
  
If the network administrator is familiar with the content exchange technology, he can use the Web content exchange technology based on the cookie field in the HTTP header to improve the service for specific customers. If he can find some rules from the HTTP request, it can also be used to make various decisions. In addition to the problem of TCP connection tables, how to find appropriate HTTP header information and make load balancing decisions is an important issue affecting the technical performance of Web content exchange. If the Web server has been optimized for special features such as image service, SSL conversation, and Database Transaction Service, using this layer of traffic control can improve network performance.
  
Network Access Protocol exchange
  
Large networks are generally composed of a large number of specialized technical devices, such as firewalls, routers, 3rd, layer-4 switches, Server Load balancer devices, buffer servers, and Web servers. How to organically combine these technical devices is a key issue that directly affects network performance. Many vswitches now provide the layer-4 switching function to provide a consistent IP address and map it to multiple internal IP addresses. For each TCP and UDP connection request, according to the port number, dynamically select an internal address according to the specified policy to forward data packets to this address, so as to achieve load balancing. Many hardware vendors integrate this technology into their vswitches as a function of layer-4 switching, generally, the Server Load balancer policy is randomly selected and assigned based on the server connection quantity or response time. Because address translation is relatively close to the lower layer of the network, it is possible to integrate it into hardware devices. Generally, such hardware devices are LAN switches.
  
The so-called layer-4 Switching Technology of LAN switches is to exchange virtual connections based on IP addresses and TCP ports, and send data packets directly to the corresponding ports of the target computer. The vswitch connects the initial external connection requests with multiple internal addresses, and then the established virtual connections can be exchanged. Therefore, some LAN switches with layer-4 Switching capabilities can be used as a hardware Load balancer to achieve server load balancing.
  
Because the layer-4 switching is based on the hardware chip, the performance is very good, especially for the network transmission speed and switching speed far exceeds the normal packet forwarding speed. However, because it is implemented by hardware, it is not flexible enough to handle load balancing of several of the most standard application protocols, such as HTTP. Currently, Server Load balancer is mainly used to solve the problem of insufficient server processing capability. Therefore, the advantages of high network bandwidth brought by the switch cannot be fully utilized.
  
The operating system-based layer-4 switching technology was born. Through open-source Linux, core functions of layer-4 switching are implemented at the core layer of the system to process IP packets in a relatively efficient and stable core space, its efficiency is no worse than that of a hardware switch using a proprietary OS. At the same time, Server Load balancer Policy Support Based on switching core can be added at the core layer or user layer. Therefore, the flexibility is far higher than that of the hardware system, and the cost has better advantages.
  
Transmission link Aggregation
  
To support increasing bandwidth applications, more and more PCs use faster links to connect to the network. However, the business volume distribution in the network is unbalanced. The core is high, the edge is low, the key department is high, and the General Department is low. As the computer processing capability is greatly improved, people have higher requirements on the Multi-Working Group LAN processing capability. When the enterprise's internal demand for high-bandwidth applications increases (such as Web access, document transmission, and Intranet connections), data interfaces in the core areas of the LAN will cause bottlenecks, the bottleneck prolongs the response time of customer application requests. In addition, the LAN is scattered, and the network itself has no protection measures for the server. An unintentional action (like kicking the plug of the network cable) will disconnect the server from the network.
  
Generally, the countermeasure to solve the bottleneck problem is to increase the capacity of the server link so that it exceeds the current demand. For example, you can upgrade from Fast Ethernet to Gigabit Ethernet. For large enterprises, upgrading is a long-term and promising solution. However, for many enterprises, when the demand is not large enough to spend a lot of money and time to upgrade, the use of the upgrade technology is quite useless. In this case, the link aggregation technology provides a low-cost solution to eliminate bottlenecks and insecure factors on the transmission link.
  
Link aggregation technology combines the transmission capacity of multiple lines into a single logical connection. When the original line cannot meet the requirements, and the upgrade of a single line is too expensive or difficult to implement, it is necessary to adopt a multi-line solution. Currently, there are five link aggregation technologies that can "bundle" multiple lines.
  
The synchronous IMUX system works on the T1/E1 bit layer and uses multiple synchronous DS1 channels to transmit data for load balancing.
  
IMA is another multi-line Reverse Multiplexing Technology that works at the cell level and can run on platforms using ATM routers.
  
Multi-line routing is a popular link aggregation technology. routers can allocate groups to parallel links based on the buffer size (cache) of known destination addresses, you can also use the cyclic Distribution Method to distribute packets to the line.
  
Multi-link PPP, also known as MP or MLP, is a router load balancing technology that uses PPP to encapsulate data links. MP can break down large PPP data packets into small data segments and distribute them to multiple parallel lines. It can also dynamically allocate dialing lines based on the current Link Utilization. Although the speed is very slow, because packet segmentation and additional buffering increase latency, it can run well on low-speed lines.
  
Also, link aggregation occurs on the server or bridge interface card. multiple ports of the same interface card are mapped to the same IP address, balance the local Ethernet traffic to multiply the traffic passing through the server. Currently, products on the market include intel and dlink multi-port NICs. Generally, four M Ethernet ports are bound to one Nic, which greatly improves the network throughput of the server. However, this technology requires support from the driver layer of the operating system and can only be implemented in win2000 and linux.
  
The link aggregation system increases the complexity of the network, but also improves the reliability of the network, so that people can use redundant routes on the lines of key LAN segments such as servers. VRRP (Virtual routing redundancy protocol) can be used for IP systems ). VRRP can generate a virtual default gateway address. When the master router cannot be connected, the slave router uses this address to continue LAN communication. In short, when the performance of the main line must be improved and the upgrade of a single line is not feasible, the link aggregation technology can be used.
  
Server cluster with a balanced policy
  
Nowadays, servers must be able to provide a large number of concurrent access services, and their processing and I/O capabilities have become bottlenecks in service provision. If the customer's increase causes the traffic to exceed the capacity of the server, the result must be: downtime. Obviously, the limited performance of a single server cannot solve this problem. The processing capacity of a common server can only reach tens of thousands to hundreds of thousands of requests per second, millions or more requests cannot be processed within one second. However, if a system can be composed of ten such servers and all requests are evenly distributed to all servers through software technology, the system can process millions or more requests every second. This is the initial basic design concept for using Server clusters to achieve load balancing.
  
Early Server clusters often use fiber optic image cards for master-slave backup. A headache for service operators is that servers with a large number of key servers or applications and large data traffic are generally not too low-grade, the service operator often only gets the performance of one server for the cost of two servers. Address translation translates different IP addresses of network adapters of multiple servers into one Virtual IP address, so that each server is always in the working status. The work originally required to be completed by a minicomputer was completed by multiple PC servers, this type of elastic solution has a significant effect on investment protection-it not only avoids the huge equipment investment caused by rigid upgrade of minicomputers, but also avoids repeated investment in personnel training. At the same time, service operators can adjust the number of servers at any time according to business needs.
  
Network Load Balancing improves the availability and scalability of Internet server programs, such as Web servers, FTP servers, and other key task servers. A single computer can provide limited levels of server reliability and scalability. However, by connecting two or more advanced server hosts into a cluster, network load balancing can provide the reliability and performance required by the critical task server.
  
To create a high-load Web site, the distributed structure of multiple servers must be used. The combination of the proxy server and Web server mentioned above, or the mutual collaboration between the two Web servers, also belongs to the multi-server structure, but in the structure of these multi-server, each server has different roles and is an asymmetric architecture. In an asymmetric server structure, each server plays a different role. For example, one server is used to provide static Web pages, and the other is used to provide dynamic web pages. In this way, the relationship between different servers needs to be considered during webpage design. Once the relationship between servers needs to be changed, connection errors may occur on some webpages, which is not conducive to maintenance and poor scalability.
  
A load balancing network is designed with a symmetric structure. In a symmetric structure, each server is equivalent and can provide services independently without the assistance of other servers. Then, some technology can be used to evenly distribute external requests to each server in the symmetric structure, and the server that receives the connection request independently responds to the customer's request. In this structure, it is not difficult to establish a completely consistent Web server, so the Server Load balancer technology has become a key technology to build a high-load Web site.
  
In short, Server Load balancer is a strategy that enables multiple servers or multiple links to undertake some heavy computing or I/O tasks, thus eliminating network bottlenecks at a lower cost, improve the flexibility and reliability of the network.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.