3 minutes to take you to understand the load balancing service

This article is published by  NetEase Cloud .

 

An Internet product may often encounter the following difficulties when building a service: the performance and reliability of the single-node web service built cannot meet the requirements, and the node is down = abnormal service; directly using the external network to provide services, often worrying about being hacked , and the company's operation and maintenance team is relatively low-level, and the external network port will be opened accidentally. In these scenarios, if the load balancing service is added, the problem will be easily solved.

What is a load balancing service


Load balancing is one of the basic services in the modern computer field. The basic principle is to distribute traffic to the back-end service cluster through the load balancing service running in the front according to the specified load balancing algorithm, thereby providing the system with the ability to expand in parallel.

The load balancing service generally has functions such as internal and external network isolation and health check, thereby improving the security and availability of the system.

The following figure is a standard load balancing service application scenario:

 

 

Functions and Features of Load Balancing Services

 

Traffic distribution


This is the core function of the load balancing service. As a unified traffic entry, the load balancing service will distribute traffic to multiple nodes in the backend, thereby realizing the horizontal expansion of the cluster. When expansion is required, it is only necessary to add new nodes behind the load balancing service without changing the entry. For stateful services, session persistence is also required to ensure that traffic is distributed to fixed nodes.

Traffic distribution based on application layer content. There are also more complex application scenarios for Layer 7 services: web services on the external network use port 80 by default, but there are often cases where multiple websites with different domain names need to use the same egress IP. At this time, it is necessary to analyze the application layer, and distribute the traffic of the same port to different back-end services according to the user's access domain name. With the further splitting of the structure, there is still a situation in which the services of the same domain name are distributed to different backend clusters according to the URL, which requires further distribution and splitting.

System high availability


By adding multiple nodes in the backend, the availability of the service can be significantly improved. Moreover, the load balancing service generally integrates the health check function, and forwards the request to the healthy node when the backend node is abnormal, so as to realize the automatic processing of the abnormality.

Many load balancing services also provide multi-AZ support to support cross-AZ high availability and backend deployment. The service can still be available when a single computer room is down.

The load balancing service itself generally adopts special redundant equipment and special failure guarantee policies to ensure its own availability. In the cloud computing environment, load balancing services can generally provide four nine-level reliability guarantees (99.99%), and by adding multiple AZs (machine room level) or even multiple regions (regional level), the service availability can be further improved. . (Hive's multi-AZ plan will also meet with you in a few months, so stay tuned)

Online expansion/reduction


When the load balancing service is combined with cloud computing, the expansion/reduction of resources can be easily achieved, and the elastic scaling of online services can be achieved.

Taking capacity expansion as an example, when capacity expansion is required, the nodes that need capacity expansion can be initialized in advance, and then connected through load balancing to realize parallel capacity expansion of online services.

If you use the open api provided by the server, combined with other information such as monitoring, you can also implement a custom elastic scaling strategy to achieve pre-expansion during peak hours and shrinking during low-peak hours.

 

Suggestions and common misunderstandings for the use of load balancing services

 

1. Prioritize the use of stateless services


Stateful services and stateless services originally have their own advantages, and there is no obvious difference between them, but in large clusters and service-oriented scenarios, stateless services have more advantages.

Because stateful services have the advantages of easy development and high concurrency when the service architecture is relatively simple, as the scale of the business expands, it will also cause problems such as difficulty in abnormal recovery and difficulty in parallel expansion. In this scenario, stateless services have inherent advantages in service management and parallel expansion.

Generally speaking, load balancing is mostly used in scenarios with large service scale and business load, so it is more recommended to use stateless services.

2. Pay attention to the health check configuration!


Health check is one of the important functions of the load balancing service, and it is also an important criterion for the service to judge whether the backend node is alive (even the only criterion in many scenarios). It will not only affect the displayed state, but also affect the user's service quality, and even cause the entire service to be abnormal. Here are two examples:

Example 1: Health check judges that abnormal parameters are too sensitive. When the system pressure is high, it is wrongly judged and the normal nodes are removed, resulting in an increase in the pressure of the remaining nodes, so the removal operation is continued until all nodes are removed. Remove, system avalanche.

Countermeasures: In the scenario where the online pressure is high and the timeout occurs occasionally, it is recommended to use the strategy of quickly pulling up and slowing down. By appropriately lengthening the period of abnormal node downtime, the probability of wrong judgment is reduced, and the service can be quickly accessed when the service is normal to relieve the load.

Example 2: The setting time of the health check downtime parameters is too long, and the result is that the node cannot be pulled up quickly when the node is down, and user access is affected in the event of an abnormality.

Countermeasures: When the online pressure is low and the response of the health check interface is normal, you can consider shortening the downtime, so that abnormal nodes can be quickly removed in the event of an abnormality, reducing the impact on users.

Therefore, there is no fixed principle for health check parameters. The key is to look at the characteristics of the business itself, and what is most important to the business: business stability or user experience?

3. Access load balancing cannot guarantee high availability


A common misunderstanding is that service access load balancing is considered highly available. In fact, the high availability of the actual service needs to be taken into consideration, such as removing a single point from the entire link, and the service itself handling exceptions.

Therefore, the access load balancing only ensures the high availability of the access point (if the order is placed, the access is not highly available). To achieve high availability, a global guarantee is needed. Load balancing is only one way to build high availability of services. tools, not all.

4. Service acceleration will not be achieved after access to load balancing


Load balancing is a high-performance forwarding service, but for a single request, performance acceleration cannot be achieved.

If your original request takes 100ms to return, using load balancing will not shorten your request to 10ms.

And theoretically, any form of load balancing will only increase the call chain rather than shorten it (some soft load balancing, such as DNS, Service's Iptables will not increase the call chain itself, but will also add additional operations). Therefore, for a single request, the result is often slower rather than faster (generally, the added cost of load balancing services is negligible within ms, and the application is completely imperceptible).

The performance improvement of load balancing is to improve the stability of the service by sharing the parallel expansion capability brought by the load. Due to the parallel expansion of the business, the pressure on a single unit is reduced, thereby improving the overall performance of the service.

In addition, because load balancing services often have more reliable access terminals (BGP networks), more efficient forwarding facilities (dedicated forwarding devices and links), and better optimization, the general performance is still far better than the forwarding services built by themselves. . Therefore, many scenarios will have better performance.

summary


Here, the basic content of the load balancing service and the main functions and characteristics of the load balancing service are mainly introduced. The next section will enter the actual chapter, introducing how to use the load balancing service in the hive, so stay tuned.

 

 

Learn about NetEase Cloud:
NetEase Cloud Official Website: https://www.163yun.com/
New User Gift Package: https://www.163yun.com/gift
NetEase Cloud Community: https://sq.163yun.com/

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326315793&siteId=291194637