Load Balancing Knowledge

Source: Internet
Author: User

A mention of load balancing, I believe many students will directly think of nginx reverse proxy, because we are usually more familiar with Nginx to do Web services load balancing. In fact, Nginx is only part of the load balancer, and each level in the Web application actually involves load balancing.

So what is load balancing? This concept is also very important, many students have said, load balancing is not simple, is in the distributed system, the client's request evenly distributed to the server (or the upstream request, balanced allocation to the downstream of the multiple operating units), in fact, this answer only half. The balance of the request is on the one hand, on the other hand, the data is distributed evenly in the Operation unit.

Therefore, load balancing is the allocation of the request/data "evenly" to multiple operating units to execute.

  Common load Balancing scenarios

Comb the basic architecture of the Web application:

  

Normal Web Distributed Project Basic architecture level is this (multi-machine cluster I omitted no painting), divided into the client layer, reverse proxy nginx layer, site layer, service layer, data layer .

  client layer, load balancing of the reverse proxy layer

The "client layer" to "reverse proxy layer" load balancing is achieved through "DNS polling ": Dns-server for a domain name configured with multiple resolution IP, each DNS resolution request to access Dns-server, will poll to return these IPs, Ensure that the resolution probabilities for each IP are the same. These IP is Nginx's external network IP, so that each Nginx request allocation is also balanced.

  "Reverse proxy layer load Balancing at the site layer

The load balancing of "reverse proxy layer" to "site layer" is implemented by "Nginx" . by modifying nginx.conf, various load balancing strategies can be implemented, such as polling, least connection routing, IP hashing, and so on.

  the site layer, Service Tier "load Balancing

The load balancing of the "site layer" to "service tier" is achieved through the service connection pool .

  Load balancing of the "Data tier"

  In the case of large data volume, because the data layer (Db,cache) involves the horizontal segmentation of data, the load balance of the data layer is more complex, it is divided into "data equalization" and "Request equalization".

the balance of data refers to: each service (Db,cache) after horizontal slicing, the amount of data is similar.

Request equalization refers to: each service (Db,cache) after a horizontal split, the request volume is similar.

There are several common ways to slice horizontally:

  First, according to the range level segmentation:

Each data service stores a range of data, such as the DB1 service, the storage UID range 1-1kw, the DB2 service, and the storage UID range 1kw-2kw.

The benefits of this scheme are:

(1) Simple Rules , service only need to judge the scope of the UID can be routed to the corresponding storage services

(2) good balance of data

(3) relatively easy to expand , can add a uid[2kw,3kw] data services at any time

Deficiencies are:

(1) The requested load is not necessarily balanced , in general, the newly registered users will be more active than the old users, large range of service request pressure will be greater.

  

  Second, according to the ID hash level segmentation

Each data service stores some data after a hash of a key value, such as a DB1 service, storing even-numbered UID data, and a DB2 service that stores odd uid data.

The benefits of this scheme are:

(1) Simple Rules , service only need to hash the UID can be routed to the corresponding storage services

(2) good balance of data

(3) good uniformity of request

Deficiencies are:

(1) It is not easy to expand , extend a data service, when the hash method changes, data migration may be required.

Have you found that in the Distributed system Architecture design, extensibility is also a factor to be considered frequently oh!

Load Balancing Knowledge

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.