Fuse computing
10 seconds 20 times, and then calculating the number of errors exceeds the threshold value 50%, fuse open. Recovery service provider, a successful request, the fuse is closed
http://localhost:9002/actuator/health
hystrix: {
status: "CIRCUIT_OPEN",//熔断开启
details: {
openCircuitBreakers: [
"RestTemplateRequestServiceImpl::smsSend"
]
}
}
hystrix.command.default.circuitBreaker.requestVolumeThreshold 一个rolling window内最小的请求数。如果设为20,那么当一个rolling window的时间内(比如说1个rolling window是10秒)收到19个请求,即使19个请求都失败,也不会触发circuit break。默认20
hystrix.command.default.circuitBreaker.errorThresholdPercentage错误比率阀值,如果错误率>=该值,circuit会被打开,并短路所有请求触发fallback。默认50,即为50%。
View original fuse monitoring
Consumer Services Configuration
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
http://localhost:9002/actuator/hystrix.stream,访问会发现一直在ping
Visualization
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
@EnableHystrixDashboard
http: // localhost: 6101 / hystrix port server.port configuration
input original view monitoring address: http: // localhost: 9002 / actuator / hystrix.stream
Centralized visualization
To display a single focus: Turbine
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-turbine</artifactId>
</dependency>
<!-- eureka客户端 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
turbine:
app-config: api-1,api-2
cluster-name-expression: "'default'
@EnableTurbine
Address: http: // localhost: 6102 / turbine.stream, also has ping, equivalent to the original hystrix.stream, but here is the combination of all the projects.
Start hystrix-dashboard.
Visit: http: // localhost: 6101 / hystrix
Fill the above address: http: // localhost: 6102 / turbine.stream