Web server-side load balancing technology principle decryption

Source: Internet
Author: User
Tags session id

1, what is the load?

The load is the server-side "resources": the CPU and IO are the main.

The former is suitable for compute-intensive tasks, while the latter corresponds to data-intensive tasks.

2, the premise of load balancing

The load (or Cpu/io resources) can be split, divided into different computers (or CPU core) up.

To do this, first of all, the underlying operation should be interrupted and scheduled, IO can be spread more than one way. Otherwise a simple CPU dead loop instruction this:jmp This (jump back to itself) will make the computer do nothing, and Io, io if non-stop interrupt blocked the bus, the computer will also do nothing (but normally the IO bus does not have CPU internal bus fast)

3. The essence of load balancing

Since the load can be split onto different computers (distributed systems, how the consistency of these computers is maintained, how the transaction acid nature is maintained, how to improve usability, Cap/base is another topic), the remaining key is to route the external large-scale concurrent requests.

First of all, assuming that each request corresponds to the server side of a computer processing, if the external request corresponding to the load can be evenly distributed to each computer node, then load balance will certainly be more successful.

Without considering the backend technology of distributed database, the core of load balancing is routing. This route, in fact, is a hash function.

What is the input of the function? All available external user request parameters, such as user ID, session ID, request parameter, network layer address, and so on.

What is the output? Assuming the computer number of the final processing request is 1 to N, the output of the routed hash function is an integer between [1..N].

Obviously, if the input is homogeneous (random), the hash function can take a linear hash operation to ensure that the load evenly falls on the N processing nodes. There is no doubt that the input may sometimes be uneven, often fall in a local range of requests too much, which often leads to hot/bottleneck, if this part of the total number of non-uniform input samples than the total input space is not very large, in theory, can still find a can use the Non-linear hash algorithm (for example sha1/ 256 and so on, so that the input can still fall evenly on the interval [1..N].

4. Multi-level routing

In practice, the preceding routing hash operation is not performed at just one point, but may be done at multiple levels, such as: Network layer lb Technology LVs (Linux Virtual Server), front-end agent (HTTP reverse proxy with round robin polling, Database Connection Driver Agent), DNS dispatch

This can easily be reminiscent of a multilayer feedforward/feedback network in a neural network (the depth of learning is not to increase the level of the intermediate nodes), anyway, multi-level routing is actually a non-linear hash map in mathematics.

The nature of load balancing is almost the same. For practical applications, the key is to design a hash function, so that the application of specific data for this and can be evenly distributed to the back-end processing node.

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.