Evolution of large-scale website system Architecture (iii) How to improve the high availability and high performance of Web sites

Source: Internet
Author: User
Tags mysql load balancing haproxy

With the website's business more and more, the service of the website becomes very important, suppose one day your server hangs, will be a big disaster? And this kind of thing happen the probability is not small, power off, server hard disk bad, memory bad and so on, will make your system hangs, and high concurrent access sometimes will make system resources exhausted, and then lead to server outage, then the solution, that is the cluster, Put the same system on different Web servers or hardware servers, so that one of them hangs up and the website can operate normally.

Web Application Cluster

First of all we should do the Web front-end cluster, our solution is to use Haproxy to do the HTTP protocol layer load balancing, the backend deployment of multiple Web front, of course, can also use LVS, load balancing more efficient, please refer to my other blog: LVs to achieve load balancing HTTP/ Www.cnblogs.com/tangyanbo/p/4305589.html, this article is about MySQL load balancing, of course, do the Web application cluster principle is the same, of course, there are some other middleware, such as Ngnix is also possible, About load balancing middleware I'll explain it in detail in a different blog.

Performance issues for various cluster scenarios

Understanding IP Load Balancing and Data link layer load balancing requires familiarity with the TCP/IP protocol.

Reverse Proxy load Balancing

Typical reverse proxy middleware has haproxy and Ngnix, request forwarding at the HTTP protocol level, its advantages are integrated with the reverse proxy server functions, deployment is simple, the disadvantage is to do HTTP forwarding in the middleware, working in the application layer, and the request and response to go through the reverse proxy server, Easily become a performance bottleneck.

System Architecture Diagram:

IP Layer Load Balancing

Load balancing by modifying the request destination address

Concrete implementation: LVS

Pros: IP load Balancing completes IP forwarding in the kernel, better than reverse proxy performance, but requests and responses go through the IP load Balancer server, so the throughput bottleneck appears on the NIC of the IP load Balancer server.

System Architecture Diagram:

Data Link Layer Load Balancing

By modifying the MAC address to complete the request forwarding, the load balanced data distribution process does not modify the IP address, only modify the destination MAC address, by configuring the real server cluster all machine virtual IP and load Balancer IP address consistent, so as not to modify the source address and destination address of the packet can be used for data distribution purposes , because the real server IP that processing the request is consistent with the destination IP of the data request, it does not need address translation through the Load Balancer server, it can return the response packet directly to the user's browser, so as to avoid the bottleneck of the load Balancing server network card broadband.

System Architecture Diagram:

Session problem

Web applications generally need to maintain user sessions, so after the cluster will be a problem, by default, the client request is evenly distributed to the back-end server, then the same session of two requests may be assigned to different servers, then the session will be lost.

How to solve this problem?

Scenario 1 : Session Copy

is to copy the session of the 1 server to all other servers, so that no matter which server you access, you will get the user's session

Disadvantages of the program

When the number of servers is large, session synchronization becomes quite time consuming

Scenario 2 : Session viscous

When a user requests a server, other requests for the same session are assigned to the server, and the session sticky function is done by the load Balancer middleware.

The advantage of this scheme solves the performance problem of session replication.

The disadvantage of this scheme is that because the user's session is saved to a single server, a single point of failure is prone to occur.

So is there a better solution?

Scenario 3 : Session Server

Deploy a dedicated service, save the user session, at the same time in the Web server local also save a copy, when the local does not or fail to access the session server, of course, the session server becomes a single point, when the user is a large amount of time is also prone to downtime, At this point can do a session server cluster, the master backup synchronization, so that it achieves a better effect, the implementation can be used redies,memcached and other cache middleware.

System Architecture Diagram:

conclusion : Load balancing has a minimum of 2 advantages

1. Multi-point deployment, solve single point of failure problem, improve the usability of the website

2. Ability to improve system performance by leveraging additional hardware resources

Evolution of large-scale website system Architecture (iii) How to improve the high availability and high performance of Web sites

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.