The size of the Internet will double every hundred days, customers want to get the uninterrupted availability and faster system of 7 days, and do not want to see a site "Server Too Busy" and frequent systems. malfunction.
The core part of the network increases with the increase in traffic, the rapid growth of traffic, and the data traffic, and its processing capabilities and computational strength have increased accordingly, so that a single device cannot be borne. In this case, if you throw away existing devices to do a lot of hardware upgrades, this will cause waste of existing resources, and if it is facing the next business, this will lead to a high cost of hardware upgrading. Equipment invested, and even performance reappeared can not meet the current needs of current traffic. Thus, the load balancing mechanism came into being.
Load Balance is built on existing network structure, which provides a low-cost and effective way to extend the bandwidth of network devices and servers, increase throughput, strengthen network data processing power, and improve network flexibility and availability. .
Both load balancing: First, a large amount of concurrent access or data traffic is shared on multiple node devices, reducing the time waiting response; secondly, a single heavy load is shackled to multiple node devices to do parallel Processing, after each node device processing ends, collect the results, return to the user, and the system processing power is greatly improved.
The load balancing technology to be described herein is mainly to refer to the application of traffic load between all servers and applications in the balanced server group. Most of the current load balancing technologies are used to improve, such as on a web server, FTP server, and other key task servers. The availability and scalability of the Internet server program.
Load balancing technology classification
There are currently many different load balancing techniques to meet different application needs, and below from the equipment object used by the load balance (refer to the OSI reference model) and the geographic structure of the application.
Soft / hardware load balancing software load balancing solution refers to installing one or more additional software on an operating system corresponding to one or more servers to implement load balancing, such as DNS Load Balance, Checkpoint FireWall-1 ConnectControl, etc. The advantage is based on a particular environment, the configuration is simple, the use is flexible, and the cost is low, which can meet the general load balancing needs.
Software solution has more shortcomings, because additional software running on each server consumes unstactful resources, the more functional modules, the more power consumption, so when the connection request is particularly large, the software itself will Become a key to success or failure of the server; the scalability of software is not very good, limited by the operating system; due to the operating system itself, it often causes security issues.
The hardware load balancing solution is to install load balancing devices directly between servers and external networks. We usually refer to it is a load balancer. Due to dedicated devices complete special tasks, independent of the operating system, overall performance has been largely improved, Plus diversified load balancing strategies, intelligent flow management, can achieve optimal load balancing requirements.
The load balancer has a variety of forms, except as an independent load balancer, some load balancers are integrated in the switching device, and they are placed between the server and the Internet, and some will be this in two network adapters. Function is integrated into the PC, one block is connected to the Internet, and a piece is connected to the internal network of the backend server group.
In general, hardware load balancing is better than software mode, but cost is expensive.
Local / global load balancing load balancing is divided into local load balance and global load balance (Global Load Balance), local load balancing is the local server group Make load balancing, global load balancing refers to a load balance between a different geographic location and a server group with different network structures. Local load balancing can effectively solve problems with excessive data traffic, network load, and do not cost expensive speaking performance excellent server, make full use of existing equipment to avoid loss of data traffic from server single point failure. It has a flexible and diverse balanced strategy to reasonably assign data traffic to the server in the server group. Even though give an existing server expand upgrade, just simply add a new server to the service group, without changing the existing network structure, stop existing services.
Global load balancing is mainly used in a multi-zone to have its own server, in order to enable global users to access the most recent server with only one IP address or domain name, the fastest access speed can also be used for subsidiaries. Big companies with a wide range of distributions are widely distributed by intranet (enterprise internal Internet) to achieve a reasonable assignment of resource unity.
The overall load balancing has the following characteristics:
Realizing geographic location, it is possible to provide a complete transparent service for users. In addition to avoiding single point failure of servers, data centers, etc., can also avoid single point failure due to ISP line failures. Solve network congestion issues, improve server response speed, and service is available to achieve better access quality. Load balancing on the network level is located for different bottlenecks on the network, starting from different levels of the network, we can use corresponding load balancing techniques to solve existing problems.
As the bandwidth increases, the data traffic of data traffic is increasing. The data interface of the network core portion will face bottleneck problems. The original single line will be difficult to meet the needs, and the upgrade of the line is too expensive and even difficult to implement. At this time, you can consider using it. Link aggregation technology.
Link aggregation technology (second layer load balancing) uses a plurality of physical links as a single polymeric logic link, network data traffic is co-borne by all physical links in the aggregate logic link, which is logically increased The capacity of the link is great to meet the demand of bandwidth increase.
Modern load balancing techniques are typically operated in the fourth or seventh layer of the network. The fourth layer load balancing maps an IP address that is legally registered on an Internet into a multiple internal server IP address, and dynamically uses one of the internal IP addresses for each TCP connection request to achieve load balancing. In the fourth-layer switch, this equalization technique is widely used, and one target address is the server group VIP (Virtual IP, Virtual IP Address) connection request data package flow through the switch, the switch based on the source and destination IP address, TCP Or UDP port numbers and a certain load balancing policy, mapping between server IP and VIP, selecting the best server in the server group to process connection requests.
The seventh layer load balancing controls the content of the application layer service, provides a high-level control method for access traffic, suitable for the application of the HTTP server group. The seventh layer load balancing technology performs load balancing tasks according to the information within the header through the information flowing through the HTTP header.
The advantages of the seventh floor load balancing are as follows:
By checking the HTTP header, the HTTP400, 500 and 600 series of error messages can be detected, so that the connection request can be relocated to another server to avoid application layer failure. The data traffic leads to the corresponding content to the server based on the data type flowing (if it is a data packet is an image file, a compressed file or multimedia file format, etc.). According to the type of connection request, such as a static document request such as a normal text, an image, or an ASP, CGI, etc. Dynamic document requests, leading the corresponding request to the corresponding server to process, improve the system performance and security. The seventh layer load balancing is limited by its protocol restrictions (generally only HTTP), which limits its extensive application, and checks that the HTTP header will occupy a large amount of system resources, which will inevitably affect the performance of the system, in a large number of connections In the case of a request, the load balancing device itself is easily a bottleneck of the overall performance of the network. Load balancing strategy
In practical applications, we may not want to simply assign the client's service request to the internal server, regardless of whether the server is down. Instead, you want to make the Pentium III server to accept more service requests than Pentium II, and a server requested less requests to more service requests, and the failed server will no longer receive service request until fault recovery, etc. Wait.
Choose a suitable load balancing strategy to make multiple devices to complete tasks, eliminate or prevent existing network load distribution uneven, data traffic congestion is long. In each load balancing mode, there is a corresponding load balancing strategy for the second, third, four, and seven layers of the OSI reference model.
There are two key factors in the advantages and disadvantages of load balancing strategies and their implementation: 1. Load balancing algorithm, second, the detection method and ability of network system conditions.
Considering the different types of service requests, the server's different processing capabilities, and the load allocation of the random selection is uneven, in order to make the load to the internal multiple servers, the application can be applied correctly reflects each server process. Load balancing algorithm for capabilities and network status:
Round Robin: Every time a request from the network is assigned to the internal server, from 1 to N and then start again. This equalization algorithm is suitable for all servers in the server group have the same software and hardware configuration and the average service requests relatively equalized.
Weighted Round Robin: Depending on the server's different processing capabilities, assigns different weights to each server, allowing it to accept service requests with the number of weights. For example, the weight of server A is designed to 1, and the weight of B is 3, and the weight of C is 6, then the servers A, B, and C will receive 10%, 30%, and 60% of service requests, respectively. This equalization algorithm ensures that high-performance servers get more usage and avoid low performance server loads.
Random balance (Random): Randomly assigned a request from the network to multiple servers in the inside.
Weighted Random: This equalization algorithm is similar to the power wheel cycle method, but is a random selection process when processing the request share.
Response Time: The load balancing device emits a probe request (for example, ping) on the internal serve, and then determines which server to respond to the client's service request according to the fastest response time of the probe request. . Such equalization algorithms can better reflect the current operating state of the server, but the fastest response time refers only to the fastest response time between load balancing devices and servers, rather than the fastest response time between clients and servers.
LEAST Connection: Every time the client's request service will have a big difference, with the working time, if a simple rotation or random equalization algorithm is used, each server The connection process may have great different and have not reached the real load balance. The minimum connection number equalization algorithm has a data record for each server that is loaded in the internal, records the number of connections currently processing, and when there is a new service connection request, the current request is assigned to the minimum number of connections. The server makes the balance more in line with the actual situation, and the load is more balanced. This equalization algorithm is suitable for long-term processing, such as FTP. Processing ability equilibrium: This equalization algorithm will assign service request to internal processing load (depending on the server CPU model, CPU number, memory size, and current connections), which is converted to the number of connections), and considers the processing of internal servers. Ability and current network operation, so this equalization algorithm is relatively accurate, especially suitable for use to seventh layer (application layer) load balancing.
DNS Response Balance: On the Internet, both HTTP, FTP, or other service requests, clients are generally found to find the exact IP address of the server through domain name resolution. Under this equilibrium algorithm, the load balancing device of different geographic locations receive the domain name resolution request of the same client, and resolve this domain name into the IP address of the respective correspondence server (ie, with this load balancing device) On the IP address of the same geographic server) and returns to the client, the client will resolve the IP address in the first domain name to continue the request service, ignore other IP address responses. Local load balancing is meaningless in the case where the balanced strategy is suitable for global load balancing.
Although there are a variety of load balancing algorithms to be partially assigned to the server to the server, if the load balancing policy does not detect the detection and ability of the network system status, once a server or a certain load balancing device and server When there is a fault between networks, the load balancing equipment still leads a part of the data traffic to that server, which will cause a large number of service requests to be lost, not uninterruptible. So good load balancing strategies should have a network failure, server system failure, application service failure detection method and ability:
PING detection: Detecting server and network system conditions through ping, this way is simple and fast, but can only detect if the operating system on the network and server is normal, and it is powerless to detect application service on the server.
TCP Open detection: Each service will open a TCP connection to determine whether the service is normal if a TCP port is connected, the detection server, such as the 23 port of Telnet, HTTP, etc.)
HTTP URL Detection: For example, an access request to the main.html file is sent to the HTTP server. If you receive an error message, it is considered that the server has failed. The advantages and disadvantages of load balancing strategies have except that the two factors mentioned above, in some applications, we need to assign all requests from the same client to the same server to load, such as the server to register, shopping When the service request information saves the local database, the client's sub-request assigned to the same server to handle it. There are two ways to solve this problem, one is assigned to the same server based on the IP address, the client IP address and the server correspondence, the corresponding information is saved on the load balancing device; The client browser cookie makes a unique identifier to assign multiple requests to the same server processing, which is suitable for clients accessible through the proxy server.
There is also an out of path return mode. When the client connection request is sent to the load balancing device, the center load balancing device will request a server, and the server's response request is no longer returned to the center load balancing. The device, that is, bypass the flow distributor, directly returns to the client, so the center load balancing device is only responsible for accepting and forwarding requests, and its network burden has decreased a lot and provides a faster response time to the client. This mode is generally used in the HTTP server group, set a virtual network adapter on each server, and set its IP address to the server group VIP, so that the server can directly respond directly to the client to achieve three handshakes. Load balancing implementation factors load balancing programs should be the problem that should be considered at the beginning of the website, but sometimes with the explosive growth of access flow, it is much to face problems. When we introduce some kind of load balancing and even specific implementations, like many other programs, first is to determine the current and future application requirements, and then we trade between the cost and the result. In response to the current and future application needs, analyze the difference between the network bottleneck, we need to establish which type of load balancing technology, what equal equilibrium strategy is to meet how much availability, compatibility, security, etc. The need, so, wait. Regardless of whether the load balancing is a software method that spends less software, or the purchase price is high in performance-functional, the hardware mode such as the 5th floors, the load balancer is implemented, or different equilibrium technology, the following The items we may consider when we introduce a balanced scheme: performance: Performance is a key consideration when we introduce a balanced plan, but it is also the hardest problem. When measuring performance, the number of packets per second through the network can be used as a parameter, and the other parameter is the maximum number of concurrent connections that the server group can process in the equalization scheme, but it is assumed that one equalization system can handle millions of concurrency. The number of connections can only be forwarded at a rate of 2 packets per second, which is obviously nothing. The performance of the performance is related to the processing power of the load balancing equipment, and the equalization strategy is closely related, and there are two points to note: 1. The equalization of the overall performance of the server group, which is the key to responding to the client connection request speed; Second, load Balanced equipment itself, avoiding a large number of requests, and become a service bottleneck. Sometimes we can also consider using a hybrid load balancing strategy to enhance the overall performance of the server group, such as DNS load balancing combined with NAT load balancing. In addition, for sites with a large number of static document requests, it is also possible to consider using cache technology. It is relatively expensive to improve response performance; for sites with a large SSL / XML content transmission, it should consider adopting SSL / XML Acceleration technology. Scalability: IT Technology Day Coordination, the latest product in the year, now perhaps the lowest performance of the network; the number of traffic increases, a year ago, now require a new round of expansion. Suitable equilibrium solutions should meet these needs, balance the load between different operating systems and hardware platforms, equalize HTTP, email, news, proxy, database, firewall, and cache, etc., and can Dynamically increase or delete certain resources in a completely transparent manner. Flexibility: Balanced solutions should be flexibly providing different application needs to meet the constant variation of application requirements. Different server groups have different application requirements, there is a wide variety of balanced strategies. Reliability: The load balancing solution should provide complete fault tolerance and high availability for server groups in a site that requires high quality requirements. However, when the load balancing equipment is faulty, there should be a good redundant solution to improve reliability.
When using redundancy, multiple load balancing devices in the same redundant unit must have a valid manner to monitor each other, and protect the system as much as possible to suffer a loss of major faults. Easy management: Whether it is a balanced solution through software or hardware, we all want it to have flexible, intuitive and secure management, so that it is easy to install, configure, maintenance, and monitoring, improve work efficiency, avoid errors. On the hardware load balancing device, there are currently three ways to manage options: 1. Command line interface (CLI: Command Line Interface), can be managed by the HyperTerate Powerful Equalization Device Serial Interface to manage, also can Telnet remote login management In the initialization configuration, it is often necessary to use the former; two, graphical user interface (GUI: Graphical User Interfaces), there is a regular web page management, and there is also a safety management through Java Applet, which generally requires management to install someone. Version browser; three, SNMP (Simple Network Management Protocol, Simple Network Management Protocol) Support, managed by third-party network management software to manage equipment in accordance with SNMP standards. Load balancing configuration example DNS load balancing DNS load balancing technology is configuring multiple IP addresses for the same hostname in the DNS server, and when answering DNS queries, the DNS server will press the IP address of the host record in the DNS file in the DNS file. Sequential returns different resolution results, boot the client's access to different machines, so that different clients access different servers to achieve the purpose of load balancing. The advantage of DNS load balancing is simple and easy, and the server can be located anywhere on the Internet. But it also has many shortcomings: in a timely interaction of this DNS server and other DNS servers, ensure that the DNS data is updated in time, so that the address can be randomly allocated, generally set the DNS's refresh time setting, but too small will make DNS traffic increases to additional network issues. Once a server fails, even if the DNS settings are modified in time, still have enough time (refresh time) to play, during which, the client computer saved the fault server address will not access the server. DNS load balancing is a simple rotary load algorithm that cannot distinguish between server differences. Cannot reflect the current operational state of the server, and cannot achieve multi-allocation requests with better performance, and even the customer request is concentrated on a certain set. The situation on the server. To assign each server to an IP address on an Internet, this is bound to take up much IP address. It is the simplest way to determine if a site uses DNS load balancing is a continuous ping, if the IP address returned multiple times is different, then this site is likely to use a more common DNS load balancing. But not necessarily, because if the DNS response is balanced, the IP address returned multiple parsed will also be different. Try ping at www.yesky.com, www.sohu.com, www.yahoo.com is now a request for 10 servers to deal with www.test.com.
It is relatively simple to implement the UNIX system using the BIND 8.X DNS server, just add similar results in the data record: WWW1 in A 192.1.1.1 WWW3 in A 192.1.1.3 WWW in CNAME WWW1 WWW in CNAME WWW IN CNAME WWW 3 is also very simple in NT, the following detail the process of implementing DNS load balancing under Win2000 Server, NT4.0 Similar: Open "DNS" under Administrative Tools , Enter the DNS service configuration console. Open the "Properties" of the corresponding DNS server, in the Server Options of the Advanced tab, select the Enable loop check box. This step is equivalent to adding a double-byte value (DWORD value) Roundrobin in the registry record hkey_local_machine / system / currentcontrolset / service / dns / parameters, the value is 1. Turn on the corresponding area of the search area (such as Test.com), the new host adds a host (a) resource record, recorded as follows: WWW in A 192.1.1.1 WWW in A 192.1.1.2 WWW in A 192.1.1.3 Here you can see The difference is that the next host name is recorded in the next host name, but under UNIX, you will add multiple different hostnames to the corresponding IP address, and then give these hosts with one alias (CNAME ) Is implemented. It should be noted here that the local subnet priority under NT replaces the loop reputation of the multi-hoster name, so when testing, if the test-use client IP address and host resource records are in the same class mask In the range, you need to clear "Enable Netmask Sort" in the Advanced tab "Server Options". NAT load balancing NAT (Network Address Translation Network Address Translation) is simply that one IP address is converted to another IP address, generally used to convert unregistered internal addresses and legitimate, have been registered internet IP addresses. . Suitable for addressing the Internet IP address, do not want to let the interior network structure, etc. Each NAT conversion will inevitably increase the overhead of NAT devices, but this additional overhead is negligible for most networks unless there is a large number of NAT requests on the high bandwidth. NAT load balancing the external IP address into multiple internal IP addresses, dynamically converts each connection request to an address of an internal server, and leads the external connection request to the server to get the address, thereby reaching the load balancing purpose. NAT load balancing is a relatively complete load balancing technology that serves a NAT load balancing function. It is generally in the internal server to the gateway position of the external network, such as routers, firewalls, four-layer switches, dedicated load balancer, equalization algorithms. Also flexible, such as random selection, minimum connections, and response time, etc. are allocated. NAT load balancing can be implemented by software and hardware. Equipment for implementing NAT load balancing by software is often limited by bandwidth and system itself, because NAT is relatively close to the low layer of the network, therefore, it can be integrated in hardware devices, and usually such hardware devices are fourth floors. And a dedicated load balancer, an important function of the fourth-layer switch is NAT load balancing.
The following is an example in which the Cisco Router NAT load balancing configuration: there is a router with a serial interface and an Ethernet interface, and the Ethernet port is connected to the internal network. There are three web servers on the internal network, but it is just a low-end configuration. In order to handle a large number of web connection requests from the Internet, you need to make a NAT load balancing configuration on this router, convert the message sent to the Web Server Legal Internet IP address into the internal local address of these three servers. The specific configuration procedure is as follows: Do a good job of the basic configuration of the router and define that each interface is internal or external interface when doing NAT. Then define a standard access list (Standard Access List) to identify the legitimate IP address to be converted. The NAT address pool is defined to identify the local address of the internal web server. Note To use the keyword Rotary, it indicates that we want to remove the corresponding IP address from the NAT address pool using a wheelbuff in the NAT address pool. Finally, convert the target address to the message of IP IP in the access table into the IP address defined in the address pool. The configuration file is as follows:! Interface Ethernet0 / 0ip address 192.168.1.4 255.255.255.248ip nat inside interface Serial0 / 0ip address 200.200.1.1 255.255.255.248 ip nat outside ip access-list 1 permit 200.200.1.2 ip nat pool websrv 192.168!! .1.1 192.168.1.3 Netmask 255.255.255.248 Type Rotary IP NAT INSIDE DESTINATION LIST 1 POOL WebSRV Reverse Agent Load Balancing normal proxy method is a proxy internal network user access to the connection request on the server on the Internet, the client must specify the proxy server, and will be original The connection request to be sent directly to the server on the Internet is sent to the proxy server. Reverse Proxy method refers to the proxy server to accept the connection request on the Internet, then forward the request to the server on the internal network, and return the result obtained from the server to the client requesting the connection on the Internet. At this point, the proxy server is except as a server. The reverse proxy load balancing technology is to dynamically forward the connection request from the Internet in a reverse agent to the multiple servers on the internal network to achieve the purpose of load balancing. Reverse proxy load balancing can be implemented in software, such as Apache MOD_PROXY, NETSCAPE, etc., or on hardware devices such as cache, load balancer. Reverse proxy load balancing can combine optimized load balancing strategies and proxy servers, enhance the access speed of static web pages, provide beneficial performance; due to network external users do not directly access real servers, additional security Sexuality (similar, NAT load balancing technology also has this advantage). The shortcomings are mainly manifested in the following aspects: The reverse agent is in the seventh layer of the OSI reference model, so it is necessary to develop a reverse proxy server for each application service, which limits the counter-agency load balancing. The application range of technology is now generally used to balance the load balance of the web server. For each agent, the proxy server must open two connections, an external, one to one, so when the number of concurrent connection requests is very large, the load load is very large, and in the final proxy server itself will become a service. Bottleneck.