(Turn) an article thoroughly understand clearly what is load balancing

Transfer:   An article thoroughly understand clearly what is load balancing

Load balancing is a key component of a highly available network infrastructure, with load balancing, we usually can we deploy multiple application servers, and then through the load balancer to distribute the user's request to different servers to improve the site, application, database or other service performance and reliability.

 

Why introduce load balancing

 

Look at a no load balancing mechanism of web architecture:

The architecture diagram above what the defect?

First, the user is connected through a network and web servers directly, imagine if the server is hung up (this can happen at any time), then the user will not respond to the request, will not be able to access the site, which is the famous single point of failure , it certainly does not work, in general, the reliability of commercial sites on the need to meet at least four 9, that is, 99.99 & above.

Secondly, even if the server is working properly, but if many users access the server at the same time, exceed the server's processing power, it will slow to respond or even can not connect a situation, which is unacceptable to the user.

Load balancing occurs can solve the above two problems by introducing a load balancer and at least two web servers, can effectively solve both problems. Note: Under normal circumstances, all the back-end server will ensure the provision of the same content, so that users no matter which server response, can receive the same content.

As Figure architecture, now, even if App 01 even hung up, load balancing request will be forwarded App users to work on the 02, which solves the first problem above;

Secondly, according to business needs, back-end load balancing App can easily expand, so that we can solve the second problem of the above.

However, the single point of failure problem now shifted to the load balancer can be alleviated by the introduction of a second load balancer, back to it again.

 

How to select the back-end server load balancing to forward

 

The load balancer is generally based on two factors to decide you want to forward the request to which server.

1: ensure that the backend server is selected to work , to give the user a request to respond;

2: According to a preset load balancing algorithm to select from a pool of server health.

Since the load balancer should select only the back-end server can respond properly, so you need to have a mechanism to be able to judge it even back-end server is working properly. In order to monitor the health of the backend server, run status check service will periodically try to use protocol and port forwarding rules defined to connect to back-end servers. If a server does not pass health checks, it will be removed from the pool of health, to ensure that traffic will not be forwarded to the server until it through a health check up again.

 

Load Balancing Algorithm

Load balancing algorithm determines which back-end server health will be selected. Here are some commonly used algorithms, here only briefly, not specifically study the algorithm, and the back will devote an article to sum up:

Polling : select the first request to the first backend server a healthy pool, and then later select the order, until the last, and then recycled.

Minimum connection : preferred minimum number of connections, which is the minimum pressure of the back-end server in a session longer the case could be considered in this way.

Hash : The request source IP hash (hash) to select the server to be forwarded. This embodiment can be ensured to some extent a particular user can connect to the same server. If your application needs to handle state and requires the user to be able to connect to the same server before, you can consider this way.

Finally, the single point of failure problem you want to solve the load balancer can be a second load balancer is connected to the first to form a cluster. As shown below:

When the main load balancer fails, the user will need to request a second load balancer. As the DNS changes usually take effect over a longer period of time, and therefore a need for a flexible solution capable of remapping the IP address, such as a floating IP (floating IP). Such domain may remain associated with the same IP, and IP itself can be moved between servers. Here is a diagram of dynamic load balancing using floating IP architecture:

Guess you like

Origin www.cnblogs.com/icemargin/p/12529780.html