Web Load Balancing

Source: Internet
Author: User

In some cases, the expansion is obvious, such as the download service due to insufficient bandwidth and must be extended, but, other times, many people see the site performance is not satisfactory, immediately implement load balancing and other expansion means, really need to do this? Of course, the problem is only their own to answer, in addition to high availability and deployment considerations, in most cases this behavior is somewhat premature, perhaps when you read the previous chapters, your Web Server has been from 5 The station has changed back to 1 units, then all you have to do is go home to Bimensiguo. So, is it not entirely necessary to consider scale expansion at the outset? The answer is exactly the opposite, as an architect, you have to think about the future expansion plan from the start, and design the architecture for the extension, but the key is that you have to be able to realize when you need to implement the extension and have enough data to justify that necessity. It is worth mentioning that the vertical expansion of the server's own hardware is not in our discussion, this chapter we talk about the extension, mainly refers to the level of expansion, we often use scalability to reflect this expansion, so-called scalability, in fact, refers to the system by expanding the scale to enhance the ability of carrying capacity, This ability is often reflected in the increase of physical servers or cluster nodes, and so on, it can be said that the stronger the ability to carry capacity to enhance the space is greater. However, this ability is always more or less constrained, for example, we do not discuss the vertical expansion of single-machine, is because the capacity of the single-machine expansion is very limited, will soon encounter technical constraints, and as the size of the increase and more and more expensive, indeed, even the most powerful single-machine can not meet our needs.

Some thoughts on "1.1"

Load Balancing is a common means for WEB sites to scale horizontally, and before we introduce various implementations of load balancing, let's consider some of the issues.

We first turn to an example of analogy, if a company has a small team, the need to undertake a certain amount of work, at the beginning, we all do their best, very easy to complete the work, the exhilaration. However, with the development of the company, the workload of the team gradually increased, beyond the capacity of the team members, the quality of work is beginning to decline.

Outsourcing

For some consideration, the team decided to outsource part of the work to other companies to relieve their burdens, while a person in the team was responsible for long-term communication with the outsourced company, which we call the outsourced interface person. Clearly, outsourcing makes it possible to extend the capacity of the team, and as the task continues to grow, an outsourced company is unable to cope, and the team finds more outsourcing companies to work with, and the outsourced interface is responsible for communicating with the companies. In this way, the company will only need to spend a human and some costs, you can complete a large number of continuously increasing tasks.

Interface person

Suddenly one day, the outsourcing interface people because of sick leave did not come to the company to work, the company is worried, because the communication with the outsourcing company needs to be done at all times, and only the outsourcing interface person familiar with the work, which makes the original orderly outsourcing work has to be seriously affected, a number of outsourcing companies temporarily stopped, It was not until the next day that the outsourced interface man returned to the company that the outsourced work returned to normal.

Obviously, this outsourcing interface is very critical, his absence will affect the overall outsourcing of the normal conduct, which may be fatal, we call this a single point of failure (Failure), if the company relies on only one factor, system, Equipment or people, will be exposed to a single point of failure, so we should try to avoid a single point of failure.

To this end, the company has an assistant for the outsourced interface to assist him in his work, and when he is not in the company at any time, the assistant can be a good player to continue working.

Workload allocation

Just said, outsourcing interface people need to communicate with a number of outsourcing companies, and will continue to assign work tasks to them, then, in the task allocation process,

There may be situations where:

-Assigning too many tasks to some outsourcing companies, some of which were not completed on time;

-Some outsourcing companies are relatively busy, but they have not been able to assign tasks to them in time;

-Some outsourcing companies have poor business ability, but they are assigned to difficult tasks, spending a lot of time, and finally may not be completed;

-Some outsourcing companies have a strong business capability, but they are assigned a very simple task, and they spend an unnecessarily high cost of outsourcing.

As a result, we see a problem with the optimization task allocation, of course, this problem needs to be considered by the outsourcing interface, and he needs to use some process management methods to master the progress and status of the outsourcing companies, to understand the "load" of the outsourcing companies to help them more effectively assign tasks, Load balancing (Loadbalancing,LB) for outsourced work.

Risk Management

Although we have to some extent avoided the single point of failure of the outsourced interface, reducing the risk, but the outsourcing companies are still likely to have problems, in the necessary

Time, we need to take action to quickly transfer tasks to other outsourcing companies, provided that there are enough backup outsourcing companies to choose from.

From avoiding single points of failure to preparing alternatives is a series of measures to reduce the risk of outsourced work, while also guaranteeing uninterrupted operation of the outsourced work, or high availability ( HAavailability ).

Restricting

When more jobs need to be outsourced, the interface person's work is a bit overwhelming because:

-an interface person responsible for a large number of tasks, with a number of outsourcing companies to communicate, which almost cost him all the work time;

-an interface person to manage a number of outsourcing companies, has exceeded his management ability.

Clearly, these are also factors that constrain the interface's handling of more outsourced work, which limits the unlimited expansion of outsourcing.

At this time, the company decided to set up more outsourcing interface, the establishment of a new team, each of which is responsible for outsourcing interface management outsourcing companies, and follow-up related outsourcing work. The final outsourcing work Relationship Diagram :

In the above hypothetical outsourcing scenario, we encountered a series of problems and proposed solutions that were also present in the WEB site extension process .

You can still move on with these questions, and then we'll go back to the topic of Web site extensions to explore how to implement a scalable web Load Balancing system, and of course, in addition to the performance we care about, High availability will also be involved.

"2" Common load Balancing

HTTP Redirection

ForHTTPREDIRECT , you must be no stranger, it can beHTTPrequest to be transferred, inWebin the development we often use it to complete automatic jump, such as the user login success after the jump to the appropriate management page. This redirection is entirely determined by theHTTPdefined, and by theHTTPAgents andWebThe server is implemented together. Very simple, whenHTTPagents (such as browsers) toWebThe server requests aURLafter theWebServer can passHTTPin the response header information Locationtag to return a newURL, which meansHTTPthe agent needs to continue to request this newURL, this completes the automatic jump. Of course, if you write yourself aHTTPProxy, nor can it support redirection, which isWebreturned by the server LocationMark to turn a blind eye, though this may not conformHTTPStandard, but it depends entirely on your application needs. And it's becauseHTTPRedirection has the ability to request transfer and auto-jump, so it can be used for load balancing in addition to the various automatic jumps required by the application to achieveWebThe purpose of the extension.

DNS Load Balancing

We know thatDNS is responsible for providing the domain name resolution service, when we visit a site, we actually need to go through the site domain name of the DNS server to obtain the IP that the domain name points to Address, in this process,the DNS server completes the domain name to IP address mapping, again, this mapping can also be one-to-many, when theDNS The server acts as a Load Balancer scheduler (also called a equalizer), which, like the redirect transfer policy mentioned earlier, disperses the user's requests across multiple servers, but the implementation mechanism is completely different.

Reverse Proxy load Balancing

The core work of the reverse proxy server is to forward the HTTP request, so it works at the http level, which is the Application layer (seventh tier) in the TCP seven layer structure. Therefore, reverse proxy-based load balancing is also known as seven-tier load balancing, it is not difficult to achieve it, currently almost all major Web servers are keen to support reverse proxy-based load balancing, and then we will do Nginx the experiment of reverse proxy load balancing

IP Load Balancing

In fact, in the Data Link layer (the second layer), the network layer (the third layer) and the transport layer (four layers) can achieve different mechanisms of load balancing, but the difference is that these load Balancer Scheduler work must be done by the Linux kernel, Because we want the network packet to be forwarded to the other actual server as early as possible before it enters the process user address space from the kernel buffer, yes,theLinux kernel can certainly do it, netfilter in the kernel and IPVS can solve problems, and user-space applications are helpless. On the other hand, because the scheduler can work under the application layer, these load-balancing systems can support more network service protocols, such as FTP ,SMTP , DNS , as well as applications such as streaming media and Vo I P .

Web Load Balancing

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.