hystrix基础入门

转载请注明出处 http://www.paraller.com
原文排版地址 点击跳转

image

Turbine

在复杂的分布式系统中,相同服务的节点经常需要部署上百甚至上千个,很多时候,运维人员希望能够把相同服务的节点状态以一个整体集群的形式展现出来,这样可以更好的把握整个系统的状态。 为此,Netflix提供了一个开源项目(Turbine)来提供把多个hystrix.stream的内容聚合为一个数据源供Dashboard展示。

pom.xml

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-turbine</artifactId>
</dependency>

application.yml

turbine: 
  appConfig: yea-service
  aggregator: 
    clusterConfig: default
    clusterNameExpression: new String("default")
  • turbine.appConfig :配置Eureka中的serviceId列表,表明监控哪些服务
  • turbine.aggregator.clusterConfig :指定聚合哪些集群,多个使用”,”分割,默认为default。可使用http://.../turbine.stream?clu...{clusterConfig之一}访问
  • turbine.clusterNameExpression :

    • clusterNameExpression指定集群名称,默认表达式appName;此时:turbine.aggregator.clusterConfig需要配置想要监控的应用名称;
    • 当clusterNameExpression: default时,turbine.aggregator.clusterConfig可以不写,因为默认就是default;
    • 当clusterNameExpression: metadata[‘cluster’]时,假设想要监控的应用配置了eureka.instance.metadata-map.cluster: ABC,则需要配置,同时turbine.aggregator.clusterConfig: ABC

在入口程序中添加注释

@EnableTurbine

测试

http://localhost:8001/turbine.stream

PS:在添加了 hystrix的程序里面添加turbine ,会导致 /hystrix.stream 链接无效。
建议新建一个项目,然后添加 turbine的功能,不要在微服务中添加。

其他知识点

Hystrix Timeouts And Ribbon Clients

当Hystrix和ribbon配合使用的时候,如果希望 Hystrix的超时时间大于ribbon配置的超时时间,你要考虑到重试次数,例如 Ribbon的超时时间是一秒,重试三次,那你的 Hystrix超时时间必须大于三秒。

引入 hystrix需要的Jar包
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

参考链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值