Using load balancing technology to build high-load network sites

  
The rapid growth of the Internet has enabled multimedia network servers, especially Web servers, to rapidly increase the number of visitors, and network servers need to have the ability to provide a large number of concurrent access services. For example, Yahoo receives millions of access requests every day, so CPU and I/O processing power can quickly become a bottleneck for servers that provide heavy-duty Web services. Simply improving hardware performance does not really solve this problem, because the performance of a single server is always limited. Generally speaking, a PC server can provide about 1000 concurrent access processing capabilities, and a more advanced dedicated server. Being able to support 3000-5000 concurrent accesses is still unable to meet the requirements of a heavily loaded website. In particular, network requests are bursty. When certain major events occur, network access will rise sharply, causing network bottlenecks. For example, the Clinton magazine published on the Internet is a clear example. Multiple servers must be used to provide network services and network requests are assigned to these servers to provide the ability to handle large numbers of concurrent services. When using multiple servers to share the load, the easiest way is to use different servers in different ways. When splitting according to the provided content, one server can be used to provide a news page, and the other can be used to provide a game page; or can be divided by the function of the server, and one server is used to provide static page access, and Others are used to provide dynamic page access, such as CGI, that consumes a lot of resources. However, due to the suddenness of network access, it is difficult to determine the load caused by those pages is too large, and if the page of the service is too thin, it will be very wasteful. In fact, the pages that cause excessive load are often changing. If you want to adjust the server where the page is located according to the load changes, it will cause great problems for management and maintenance. Therefore, this segmentation method can only be adjusted in a large direction. For a heavily loaded website, the fundamental solution also needs to apply load balancing technology. In the concept of load balancing, multiple servers are symmetric, and each server has an equivalent status. Both services can be provided separately without the assistance of other servers. Then, through some load sharing technology, the externally sent request is evenly distributed to a server in the symmetric structure, and the server receiving the request independently responds to the client's request. Since the establishment of a web server with identical content is not complicated, it can be done by using methods such as server synchronization update or shared storage space. Therefore, load balancing technology is a key technology for building a high-load Web site. 1. Load balancing based on specific server software (access redirection)
Many network protocols support the "redirect" function. For example, the Location command is supported in the HTTP protocol. The browser that receives this command will automatically Directed to another URL specified by Location. Since sending a Location command is much less load on the Web server than executing a service request, a load-balanced server can be designed based on this function. Whenever the web server thinks it has a heavy load, it will not send it directly back to the web page requested by the browser. Instead, it will send back a Locaction command to let the browser get the required web page on other servers in the server cluster. In this way, the server itself must support this function, but there are many difficulties in implementing it. For example, how can a server guarantee that the server it redirected is idle and will not send the Location command again? The Location directive and the browser do not have this support, which makes it easy to form an infinite loop on the browser. Therefore, this method is rare in practical applications, and there are fewer server cluster software implemented in this way. In some cases, CGI (including the use of FastCGI or mod_perl extensions to improve performance) can be used to simulate this way to share the load, while the Web server still maintains a simple and efficient feature, in which case the task of avoiding the Location loop will be handled by the user's CGI program. Come to bear. 2. DNS-based load balancing (multi-machine single domain name load)
Because server-based software load balancing requires software changes, it is often worth the loss. Load balancing is best done outside the server software. Take advantage of the advantages of existing server software. The earliest load balancing technology is implemented by random name resolution in the DNS service. In the DNS server, the same name can be configured for multiple different addresses, and the client that finally queries the name will get the name when parsing the name. One of the addresses. Therefore, for the same name, different clients get different addresses, and they also access the Web server at different addresses to achieve load balancing. For example, if you want to use three web servers to respond to HTTP requests from www.exampleorg.org.cn, you can set the domain's DNS server's data about the domain to include results similar to the following example: www1 IN A 192.168.1.1 Www2 IN A 192.168.1.2 www3 IN A 192.168.1.3 www IN CNAME www1 www IN CNAME www2 www IN CNAME www3 After this, the external client may randomly get the different address corresponding to www, then the subsequent HTTP request is sent to the different The address is up. The advantage of DNS load balancing is that it is simple and easy to implement, and the server can be located anywhere on the Internet and is currently used on Web sites including Yahoo. However, it also has a number of shortcomings. One drawback is that in order to ensure timely update of DNS data, it is generally necessary to set the DNS refresh time to be small, but too small will cause too much extra network traffic, and after changing the DNS data. It can't take effect immediately; the second point is that DNS load balancing can't know the difference between servers. It can't allocate more requests for better-performing servers, nor can it know the current state of the server, or even the customer request concentration. Occasional situation on a server. 3. Reverse proxy load balancing (buffer pool)
Using a proxy server can forward requests to an internal web server. Using this acceleration mode can obviously improve the access speed of static web pages. Therefore, you can also consider using this technology to allow the proxy server to evenly forward requests to one of multiple internal web servers for load balancing purposes. This proxy method is different from the normal proxy method. The standard proxy method is that the client uses the proxy to access multiple external web servers. This proxy method is used by multiple clients to access the internal web server, so it is also called reverse. Proxy mode. Implementing this reverse proxy capability is not a particularly complex task, but requires particularly high efficiency in load balancing, which is not very straightforward to implement. For each agent, the proxy server must open two connections, one for the external connection and one for the internal connection, so when the number of connection requests is very large, the load of the proxy server is very large, at the end A reverse proxy server can become a bottleneck for services. For example, when using Apache's mod_rproxy module to implement load balancing, the number of concurrent connections provided is limited by the number of concurrent connections to Apache itself. In general, it can be used to make the number of connections not particularly large, but each connection requires a site that consumes a lot of processing resources for load balancing, such as searching. The advantage of using a reverse proxy is that you can combine load balancing and proxy server caching techniques to provide beneficial performance with additional security, and external clients cannot directly access real servers. And it can achieve a better load balancing strategy, and the load can be distributed to the internal server in a very balanced manner, without the accidental phenomenon that the load is concentrated on a certain server. 4. NAT-based load balancing technology (intranet cluster and four-layer switching)
Network address translation is to convert between internal address and external address, so that a computer with an internal address can access the external network. When a computer in the external network accesses an external address owned by the address translation gateway, the address translation gateway can forward it to a mapped internal address. Therefore, if the address translation gateway can evenly convert each connection to a different internal server address, then the computers in the external network communicate with the server at the address obtained by the conversion, thereby achieving load sharing. Address translation can be implemented in software or in hardware. Operation using hardware is generally referred to as switching, and when the exchange must hold TCP connection information, this operation for the OSI network layer is called Layer 4 switching. Supporting load balancing network address conversion is an important function of Layer 4 switches. Because it is based on customized hardware chips, its performance is very good. Many switches claim to have 400MB-800MB Layer 4 switching capability. However, there are some materials. It shows that at such a fast speed, most switches no longer have the fourth layer switching capability, but only support the third layer or even the second layer switching. However, for most sites, the current load balancing is mainly to solve the bottleneck of the processing power of the Web server, rather than the network transmission capability. The Internet connection bandwidth of many sites is only 10MB in total, and only a few sites can have higher-speed network connections. Therefore, it is generally not necessary to use expensive equipment such as these load balancers. Using software to implement load balancing based on network address translation is much more practical. In addition to the solutions provided by some vendors, a more effective method is to use free free software to accomplish this task. This includes the NAT implementation in the Linux Virtual Server Project, or the revision of the natd by FreeBSD. Generally speaking, using this software to implement address translation, the central load balancer has a bandwidth limitation. Under the condition of 100MB Fast Ethernet, it can get up to 80MB of bandwidth. However, in practical applications, it may only be 40MB- 60MB of available bandwidth. 5. Extended load balancing technology
The above use network address translation to achieve load sharing, no doubt all network connections must pass through the central load balancer, then if the load is so large, the number of servers in the background There are no more than a few, more than a dozen, but hundreds or even more, even if you use a good performance hardware switch, you will encounter bottlenecks. At this point, the problem will be transformed into how to distribute so many servers to multiple locations on the Internet and distribute the network. Of course, this can be achieved by using both DNS and NAT methods. However, a better way is to use a semi-central load balancing method. In this semi-central load balancing mode, when the client requests to send to the load balancer, the central load balancer packages the request and sends it to a server, and the server's response request is no longer returned to the central load balancer. Instead, it is returned directly to the customer, so the central load balancer is only responsible for accepting and forwarding requests, and its network burden is small. The hardware implementation of this method is also very expensive, but it has different special functions, such as support for SSL, depending on the manufacturer. Because this method is more complicated, it is difficult to implement, and its starting point is also very high. In the current situation, the website does not need such a large processing power. Comparing the above load balancing methods, DNS is the easiest and most commonly used to meet general needs. However, if further management and control are required, reverse proxy or NAT can be used. The choice between the two depends mainly on whether the buffer is important and the maximum number of concurrent accesses. If the CGI program on the website that has a strong impact on the load is developed by the website itself, you can also consider using Locaction to support load balancing in the program. The semi-centralized load sharing method is not needed at least in the current domestic situation.

Copyright © Windows knowledge All Rights Reserved