Article title: server load balancer with multiple NICs under Linux server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. INTRODUCTION today, almost all industries have built their own serversBecause of the special position of the server, its reliability, availability and I/O speed become very important. maintaining the high availability and security of the server is an important indicator of the enterprise IT environment, one of the most important aspects is the high availability of server network connections. to meet these requirements, most servers now adopt multi-Nic configurations, and most of the systems use linux, which is currently very popular, as the server working environment. Bandwidth is no longer the bottleneck for improving service quality, and the processing capabilities of network devices and servers gradually become a new bottleneck. To improve the availability and reliability of server network connections, at present, Sun's Trunking technology, 3Com's DynamicAccess technology, and Cisco's Etherchannel technology are all studying the link aggregation technology that binds multiple NIC interfaces of the server, the link aggregation technology virtualizes multiple links into one logical link, which provides a cheap and effective way to expand the bandwidth of network devices and servers and improve network flexibility and availability.
This article introduces the bonding technology in linux. this technology is used in linux 2.4.x kernel. with bonding technology, you can bind multiple NIC interfaces to a virtual Nic, in the user's opinion, this aggregated device seems to be a separate Ethernet interface device. Generally speaking, multiple NICs have the same IP address and are connected to a logical link in parallel. In linux bonding technology, there are several algorithms to achieve load balancing requirements. This article analyzes and studies these algorithms here to discuss their shortcomings, in addition, an improved load balancing implementation method based on transmission protocol is proposed. This article discusses how to implement the balancing of multiple network interfaces and failover.
II. Introduction to server load balancer technology and high availability technology
2.1 Server load balancer technology the main idea of server load balancer technology is how to evenly distribute network service traffic to different servers and network devices based on an algorithm, to reduce the burden on a single server and network device, thus improving the efficiency of the entire system. Server load balancer can be implemented either by hardware with the server load balancer function or by some special software. server load balancer is a policy, it allows multiple servers or links to undertake some heavy computing or I/O tasks, eliminating network bottlenecks at a low cost, and improving network flexibility and reliability.
The 2.2 high availability technology is first proposed based on the high availability of the network, and the high availability technology is a branch of the fault tolerance technology. Redundancy is the simplest way to achieve high availability of the system. The complete network load balancing and high availability network technology are composed of two aspects: one is multi-server binding and load balancing, and the other is a server load balancer bound with multiple NICs, here we mainly discuss the server load balancer when multiple NICs are bound to a server.
III. simple implementation of server load balancer in Linux bonding technology
3.1 Linux bonding technology is a virtual layer implemented on top of the NIC driver and under the data link layer. through this technology, multiple NICs connected to the vSwitch by the server are not only bound to one IP address, but also the MAC address. in this way, a virtual Nic is formed, and the workstation requests data from the server, after the network adapter on the server receives the request, the network adapter intelligently determines who will process the data transmission based on a certain algorithm. Bonding technology can improve the network throughput and availability of hosts.
3.2 there are several sending balancing algorithms in Linux. Currently, there are three main sending algorithms in Linux: Round-Robin and Active-Backup) MAC address or algorithm (MAC-XOR ). the following is a simple analysis of the three main algorithms.
3.2.1 rotation algorithm the algorithm is based on the principles of fairness. it selects the sending interface for each data packet to be sent. The main idea of the algorithm is that the first data packet is sent by one interface, another data packet is sent by another interface, and the following is selected cyclically. Through analysis, we can see that this algorithm is relatively simple and fair in terms of data sending. it can ensure load balancing when the Nic sends data, and the resource utilization is very high. However, we know that if a connection or session data packet is sent from different interfaces and then goes through different links in the middle, there may be a problem of unordered data packets arriving at the client, unordered packets need to be sent again, so the network throughput will decrease.
3.2.2 backup algorithm this algorithm sets one interface of multiple NIC interfaces as active, and other interfaces as standby. When an active interface or active link fails, start the standby link. this algorithm can provide high network connection availability, but its resource utilization is low, only one interface is in the working state. when there are N network interfaces, the resource utilization is 1/N. 3.2.3 MAC address difference or algorithm the main idea of this algorithm is: the MAC address of the server and the MAC address of the client jointly determine the sending port number of each data packet, the source MAC address and target MAC address are used for XOR calculation, and the XOR result is used to calculate the number of interfaces. Because the data streams sent to the same client pass through the same link, data packets can arrive at the client in an orderly manner. When only one client accesses the server or the server and the client are not in the same subnet, the algorithm determines that the load will not be balanced in this case. when only one client accesses the server, resource Utilization is also 1/N (N is the number of interfaces ).