High availability related concepts of Dubbo distributed architecture

        High availability: refers to in a distributed system or architecture, after a series of designs, reducing the time when the system cannot provide services to improve the availability of the system and applications.

1. Zookeeper is down and directly connected to dubbo

Question: The zookeeper registration center is down, can consumers still call the services exposed by the provider? Can the service be called without a registration center?

Answer: yes

reason:

Robustness

1. The downtime of the monitoring center will not affect the use, but will only lose some sampling data.

2. After the database is down, the registration center can still provide service list queries through the cache, but it cannot register new services.

3. Registration center peer-to-peer cluster, if any one fails, it will automatically switch to another one.

4. After all registration centers are down, service providers and service consumers can still communicate through local cache.

5. The service provider is stateless. If any one of them goes down, the use will not be affected.

6. After all service providers are down, the service consumer application will be unable to use and will have to reconnect indefinitely waiting for the service provider to recover.

        Even if we don't have a registration center, we can use Dubbo's direct connection method to allow consumers to reference the services exposed by the provider: where the method provided by the provider needs to be called remotely, use the @Reference annotation for direct connection injection.

//    @Reference  //dubbo会自动去注册中心找这个暴露出来的服务
    @Reference(url = "172.0.0.1:20880")  //本机提供者应用的具体url
    UserService userService;

2. Load balancing strategy

        Load Balance (LB) is an indispensable key component of a high-concurrency and high-availability system. The goal is to use a specific algorithm to try to evenly distribute network traffic to multiple servers to improve the overall response speed and performance of the system. Availability.

        1. Random (Random LoadBalance)

                The server is called randomly, but with random probabilities set by weight. The larger the call volume, the more even the distribution will be, and the weight will be more even after using the weight according to probability, which is conducive to dynamically adjusting the provider weight.

        2. Polling (RoundRobin LoadBalance)

                Each server is called in a loop, and the round robin ratio can also be set according to the weight (for example). However, there is a problem of slow providers accumulating requests. For example, the second machine is very slow but does not hang. When the request is transferred to the second machine, it is stuck there. Over time, all requests are stuck on the second machine. .

        3. LeastActive LoadBalance

                Distribute requests to the candidate server with the smallest number of connections/requests (the server currently handling the fewest requests).

        4. Consistent Hash (ConsistentHash LoadBalance)

                Calling the same method with the same parameters, according to Hash distribution, will call the same server every time

3. Service downgrade

        When server pressure increases dramatically, some services and pages may be strategically not processed or processed in a simple manner based on actual business conditions and traffic, thereby releasing server resources to ensure the normal or efficient operation of core transactions. You can use the service degradation function to temporarily block an errored non-critical service and define a return strategy after degradation.

       To put it simply: sacrifice one person to preserve the overall situation.

       For example, now that the server is running many functions (order generation, user management, advertising, etc.), it has reached its limit and cannot be turned around quickly. We can temporarily stop or simply process the advertising business to release processor resources and process other cores first. business to achieve more efficient operations.

        

         At this time, you can select "Shield" or "Fault Tolerance" in dubbo's visual interface to downgrade the service.

 

        (1) Shielding: means that the consumer's method calls to the service will directly return null values ​​and no remote calls will be initiated. Used to shield the caller from the impact when unimportant services are unavailable.

        (2) Fault tolerance: It means that after the consumer fails to call the method of the service, it returns a null value and does not throw an exception. Used to tolerate the impact on callers when unimportant services are unstable.

Guess you like

Origin blog.csdn.net/weixin_64709241/article/details/129768445