"From a large Web site technology architecture" load Balancing method

Source: Internet
Author: User
Tags http redirect varnish

1.http REDIRECT Load Balancing

The HTTP redirect server is a normal application server whose only function is to compute a real Web server address based on the user's HTTP request and write the Web server address to the HTTP redirect Response (location header)

The status code is 302, which is returned to the user's browser. Both the load server and the Web server are the IP of the public network.

This kind of load balancing is relatively simple, the disadvantage is that the browser needs two times to complete a visit to the server, performance is poor, the redirect server itself may become a bottleneck, rarely used.

2.DNS Domain name resolution load Balancing

This is a scenario that uses DNS to handle the simultaneous process load balancing of domain name resolution requests.

Configure multiple A records in a DNS server, such as www.mysite.com in a 114.100.80.1, www.mysite.com in a 114.100.80.2,www.mysite.com in a 114.100.80.3

Each domain name resolution request calculates a different IP address return based on the load balancing algorithm, which achieves the purpose of load balancing. The question is, so how does the session share after load Balancing? For example, the first load to server A, the second load to Server B, then how the session a server saved can also be accessed on the B server? (The first, the value of the session is encrypted in the cookie, each time the server access to the server, and the second, using memcached, database, Redis, etc., to save the session on a separate server, All Web servers can access this session server, then solve the problem of sharing, the commonly used method is to encrypt the stored in the cookie. )

DNS domain name resolution load Balancing has the advantage of transferring load balancing to DNS, eliminating the hassle of web site management to maintain load balancing servers, and many DNS support for geo-location-based domain name resolution, which resolves the domain name to a server that is the best location for users and speeds up access. The disadvantage is that each level of DNS may cache a record, it takes a long time to take effect (as if 10 minutes), during this time, the DNS will still resolve to the server has been offline, resulting in user access failure.

The architecture of a large web site is generally DNS as the first level of load balancing, the structure is DNS (load Balancing) and intranet load balancer server (such as Lvs,nginx)->web server

3. Reverse proxy load balancing (e.g. varnish, squid, nginx)

The reverse proxy is generally used to cache resources to improve the performance of the site, (the first time the resource access, the reverse proxy will forward the request to the resource server, then cache the resources, and then return to the user, the second time, directly from the reverse proxy to obtain resources, return to the user, such as Nginx static resource cache, CGI cache; varnish can cache resources, if it is. PHP end of the request is forwarded to the FASTCGI server, etc.), the Web server is not directly external access, so the Web server does not require external IP, reverse proxy server requires two network cards, configure an external network, an intranet IP.

The downside is that all requests and responses go through them, so it's possible to become a bottleneck.

4.IP Load Balancer (LVs's virtual Server via Network address Translation (Vs/nat) method, IP addressing override method, detailed explanation can be seen on LVS articles)

After the request arrives at the Load Balancer server, the Load Balancer server chooses a back-end Web server IP based on the load balancing algorithm, then changes the destination IP of the request to the IP of the Web server, changes the requested source address to its own IP, and then forwards the request to the Web server, Both the request and the response go through the Load Balancer server. Another approach is to use the Load Balancer server as a gateway to the real physical server cluster, so that all requests reach the Load Balancer server.

IP load Balancing is the completion of data distribution in the kernel process (see the LVS article for a detailed introduction), and better processing performance than the reverse proxy load balancer (at the application layer). But all requests and responses go through a load-balanced server, so it can be a bottleneck.

5. Data Link Layer load Balancing (LVS virtual Server via Direct Routing (VS/DR)) (most efficient, most used method)

Data link layer load Balancing refers to the data link layer of the communication protocol to modify the MAC address load balancing, the detailed content can see the introduction of the Dr Method of LVs.

"From a large Web site technology architecture" load Balancing method

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.