background

Avalanche effect: In the distributed system in the service, the service is calling each other between, regardless of the external factors, when the service is not available, call the service will be forced to wait until A service B timeout, A request corresponding to A single thread, mandatory waiting thread block, this thread will be released when the request timeout, in high concurrency application system, over time, Eventually the thread runs out and service B becomes unavailable. The lower-layer service causes the upper-layer service to become unavailable and gradually expands the service scope.

Common fault tolerance schemes

  • timeout
  • Current limiting
  • The warehouse wall model
  • The circuit breaker

Integration of the Sentinel

  1. Rely on
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Copy the code
  1. configuration
management:
  endpoints:
    web:
      exposure:
        include: The '*'
Copy the code
  1. Start the visithttp://localhost:9001/actuator/sentinelIf the response result is as follows, the integration is successful
{
    "appName":"mg-user-service"."consoleServer":"localhost:8080"."coldFactor":"3"."rules": {"systemRules": []."authorityRule": []."paramFlowRule": []."flowRules": []."degradeRules":[]
    },
    "metricsFileCharset":"UTF-8"."filter": {"order":- 2147483648.."urlPatterns": ["/ *"]."enabled":true
    },
    "totalMetricsFileCount":6."datasource": {},"clientIp":"192.168.0.102"."clientPort":"8719"."logUsePid":false."metricsFileSize":52428800."logDir":"/Users/gaozaoshun/logs/csp/"
}
Copy the code

Sentinel Console setup