Hystrix熔断-计算及可视化

熔断计算

10秒20次,再计算错误次数超过阈值50%,熔断开启。服务提供者恢复,成功请求一次,熔断关闭

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%。

原始查看熔断监控

服务消费者配置

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

http://localhost:9002/actuator/hystrix.stream,访问会发现一直在ping

可视化

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
		</dependency>
		@EnableHystrixDashboard

http://localhost:6101/hystrix 端口为server.port配置
输入原始查看监控地址:http://localhost:9002/actuator/hystrix.stream

集中可视化

由单个到集中显示: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

地址:http://localhost:6102/turbine.stream,也是一直ping,相当于原来的hystrix.stream,不过此处是综合了所有的项目。

启动hystrix-dashboard。

访问:http://localhost:6101/hystrix

填上上面的地址:http://localhost:6102/turbine.stream

可视化图例

在这里插入图片描述

发布了25 篇原创文章 · 获赞 0 · 访问量 566

猜你喜欢

转载自blog.csdn.net/RaymondCoder/article/details/105316726
今日推荐