Sentinel's fuse is degraded

Please see gitee for the entire project: https://gitee.com/xwb1056481167/spring-cloud

Sentinel installation and project integration: https://blog.csdn.net/www1056481167/article/details/113679945

jmeter download address https://archive.apache.org/dist/jmeter/source/#sig (simulate concurrent use)

Note: Inside the interface used in micro-services cloudalibaba-sentinel-service8401 in

  • RT (average response time)

Select the slow call ratio as the threshold, and you need to set the allowable slow call RT (that is, the maximum response time). If the response time of the request is greater than this value, it will be counted as a slow call. When the number of requests in the unit statistical time (statIntervalMs) is greater than the set minimum number of requests, and the proportion of slow calls is greater than the threshold, the requests will be automatically blown during the next fusing time. After the fusing time, the fuse will enter the detection recovery state (HALF-OPEN state). If the response time of the next request is less than the set slow call RT, it will end the fusing. If it is longer than the set slow call RT, it will be blown again.

  • Abnormal ratio

When the number of requests per unit of statistical time (statIntervalMs) is greater than the set minimum number of requests, and the proportion of abnormalities is greater than the threshold, the requests will be automatically blown during the next fusing time. After the fusing time, the fuse will enter the detection recovery state (HALF-OPEN state). If the next request is successfully completed (without error), it will end the fusing, otherwise it will be blown again. The threshold range of the abnormal rate is [0.0, 1.0], which represents 0%-100%.

  • Number of exceptions

When the number of abnormalities in the unit statistical time exceeds the threshold, it will automatically be fused. After the fusing time, the fuse will enter the detection recovery state (HALF-OPEN state). If the next request is successfully completed (without error), it will end the fusing, otherwise it will be blown again.

Slow call ratio (SLOW_REQUEST_RATIO)

Average response time, the number of requests that exceed the threshold  and  passed within the time window >=5, both conditions are met at the same time to trigger downgrade

@GetMapping("/testD")
public String testD() {
    try {
        TimeUnit.SECONDS.sleep(1);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    log.info("testD 测试RT");
    return "-----------testD";
}

RT configuration (average response time)

Average response time

Always execute 10 threads per second (greater than 5), and hope to complete execution in 200 milliseconds. If it exceeds 200 milliseconds, the circuit breaker is opened (fuse tripping) service is unavailable, and the fuse trips and powers down.

Exception ratio (ERROR_RATIO)

When QPS>=5, and the abnormal ratio (second-level statistics) exceeds the threshold, the downgrade is triggered, and the downgrade is closed after the time window is over 

1. New test category

@GetMapping("/testC")
public String testC() {
    int a = 10 / 0;
    return "-----------testC";
}

2. Set the abnormal ratio

Setting meaning: 10 visits per second (more than 5 visits per second in accordance with the official website regulations), and then if the proportion of these visits fails exceeds 30%, the service will be degraded. After entering the testC method, all of them failed. The access and service in the next 5 seconds are all fused, and the normal access will be restored after 5 seconds. Just keep repeating.

If jmeter is closed, the test is closed and the browser is refreshed. At this time, the set abnormal ratio will not be taken (because the QPS visit volume is not enough 5), the system will be abnormal. Go runtimeException

Number of exceptions (ERROR_COUNT)

SentinelResource and Hystrix's HystrixCommand annotation have the same effect, and there is an enhanced version of alibaba.
If the number of exceptions (statistics in minutes) exceeds the threshold, the downgrade is triggered. After the time window is over, the downgrade is closed

 1. Testing

@GetMapping("/testE")
public String testE() {
    log.info("testD 测试异常数");
    int age = 10 / 0;
    return "-----------testE";
}

2. Sentinel configuration

Note: Within one minute, when accessing the testE interface, an error was reported at the beginning, after 5 consecutive visits, the trip was performed, the service was blown, and then it was downgraded and cannot be accessed.

Guess you like

Origin blog.csdn.net/www1056481167/article/details/113683673