Thread pool isolation is a common thread pool isolation for sentinel
1 Thread Isolation
It can be understood as a bulkhead isolation that divides the inner space of the ship into compartments. If one of the compartments is damaged and flooded, the water will not flow through each other, so that the ship can still have enough buoyancy and stability in case of damage, thus reducing the risk of immediate sinking.
In a highly servitized system, a business logic we implement will usually rely on multiple services, such as: the commodity detail display service will depend on the commodity service, the price service, the commodity review service. As shown in the figure:
Calling the thread pool of the three dependent services will share the commodity detail services. If the product review service is not available, then all threads in the thread pool are blocked waiting for a response, causing a service avalanche. As shown in the figure:
Hystrix avoids service avalanches by allocating separate thread pools to each dependent service for resource isolation.
2 Semaphore isolation
Hystrix’s semaphore isolation limits the proportion of abnormal calls to a resource.
Sentinel provides more policy options on the limits of semaphore isolation, based on the ratio of slow calls, the ratio of exceptions, and the number of exceptions.
2.1 Implementation Principles
Sentinel uses high-performance sliding window data structure LeapArray to count real-time second-level index data. In the basic implementation of semaphore isolation, according to different strategies, such as outliers strategy, the proportion of abnormal requests within the sliding window interval is counted to determine the fusing downgrading process of the service.
1. SLOW_REQUEST_RATIO
Set the allowed slow call RT (maximum response time). Requests whose response time is greater than this value are counted as slow calls. When the number of call requests exceeds the threshold, a fuse is triggered. Threshold setting, 100ms response, 10 requests as shown in the figure below:
2. ERROR_RATIO
If the number of requests per unit statistical period is greater than the minimum number of requests and the proportion of abnormal requests is greater than the threshold, the requests are automatically fused in the following fusing period. The threshold setting is 20% as shown in the figure below:
3. Number of exceptions (ERROR_COUNT)
When the number of anomalies in a unit statistics period exceeds the threshold, the circuit breaker is automatically disconnected. Threshold setting 5 is shown in the figure:
3 Comparison of fuse degraded components
reference
Juejin. Cn/post / 698321… Segmentfault.com/a/119000000…