首页 > 其他分享 >Hystrix Dashboard

Hystrix Dashboard

时间:2023-02-13 11:31:28浏览次数:47  
标签:hystrix Hystrix 断路器 实例 Dashboard 监控


文章目录

  • ​​1、什么是Hystrix Dashboard?​​
  • ​​2、Hystrix Dashboard(仪表盘)实现​​
  • ​​2.1 在项目中引入依赖​​
  • ​​2.2 入口类中开启hystrix dashboard​​
  • ​​2.3 启动hystrix dashboard应用​​
  • ​​2.4 被监控的项目中加入监控路径配置[新版本的坑]​​
  • ​​2.5 启动项目进行测试​​
  • ​​3、Hystrix现状​​

1、什么是Hystrix Dashboard?

  Hystrix Dashboard是Spring Cloud的仪表盘组件,可以查看Hystrix实例的执行情况,支持查看单个实例和查看集群实例,但是需要结合spring-boot-actuator一起使用。

  Hystrix Dashboard主要用来实时监控Hystrix的各项指标信息。Hystrix Dashboard可以有效地反映出每个Hystrix实例的运行情况,帮助我们快速发现系统中的问题,从而采取对应措施。

  Hystrix的主要优点之一是它收集的有关每个HystrixCommand的一组指标。Hystrix仪表板以有效的方式显示每个断路器的运行状况,具体如下图所示。

Hystrix Dashboard_Hystrix

这个Hystrix Dashboard在实现的时候会有很多坑,我会在后续的文章中写一些解决方案

2、Hystrix Dashboard(仪表盘)实现

SpringBoot版本:2.2.5.RELEASE

SpringCloud版本:Hoxton.SR6

项目结构:

仪表盘项目:

Hystrix Dashboard_Hystrix_02


两个测试服务(这两个服务的实例都是​​javascript:void(0)​​这篇文章里面的,这里只是用下仪表盘看下断路器的开关以及其他一些细节):

Hystrix Dashboard_Hystrix_03

2.1 在项目中引入依赖

<!--引入hystrix dashboard 依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>

2.2 入口类中开启hystrix dashboard

Hystrix Dashboard_spring_04


application.properties:

Hystrix Dashboard_断路器_05

2.3 启动hystrix dashboard应用

访问:​​http://localhost:9909/hystrix​

Hystrix Dashboard_spring cloud_06


从上面页面内容可发现,有几个配置项

Hystrix Dashboard支持三种不同的监控方式

  • 默认集群监控:通过URL(https://turbine-hostname:port/turbine.stream)开启,实现对默认集群的监控
  • 指定的集群监控:通过URL( https://turbine-hostname:port/turbine.stream?cluster=[clusterName])开启,实现对clusterName集群的监控。
  • 单体应用的监控:通过URL(https://hystrix-app:port/actuator/hystrix.stream)开启,实现对具体某个服务实例的监控
    Delay:默认是2000ms,主要用来控制服务器上轮询监控信息的延迟时间,通过该配置可以降低客户端的网络和CPU消耗。
    Title:标题。默认使用具体监控实例的URL。

2.4 被监控的项目中加入监控路径配置[新版本的坑]

Hystrix Dashboard_断路器_07

@Configuration
public class BeansConfig {

@Bean
public ServletRegistrationBean getServlet() {
HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
registrationBean.setLoadOnStartup(1);
registrationBean.addUrlMappings("/hystrix.stream");
registrationBean.setName("HystrixMetricsStreamServlet");
return registrationBean;
}
}

2.5 启动项目进行测试

Hystrix Dashboard_Hystrix_08


服务注册中心:

Hystrix Dashboard_spring boot_09


刚启动时:

Hystrix Dashboard_spring_10


我们测试下服务调用:

Hystrix Dashboard_Hystrix_11


再查看Hystrix Dashboard:

Hystrix Dashboard_spring_12


可以看到,这是个正常的请求,断路器是关闭的,我们测试下服务熔断时断路器的状态:(可以一直发送失败的请求,触发熔断条件)

Hystrix Dashboard_断路器_13


Hystrix Dashboard_spring cloud_14


  由上述两幅图片可看出服务熔断之后,断路器打开,当然断路器会每5秒(默认)放行一个请求,如果改请求成功,则关闭断路器,否则继续每隔5秒放行一个,一直重复。

  在断路器打开之后我们给一个正常的请求,可以看到,断路器立刻关闭。

Hystrix Dashboard_断路器_15

3、Hystrix现状

官方地址:​​https://github.com/Netflix/Hystrix​

Hystrix Dashboard_spring boot_16


翻译之后:

Hystrix Dashboard_spring boot_17

  Hystrix 不再处于积极开发阶段,目前处于维护模式。

  Hystrix(版本 1.5.18)足够稳定,可以满足 Netflix 对我们现有应用程序的需求。同时,我们的重点已转向更具适应性的实现,这些实现对应用程序的实时性能做出反应,而不是预先配置的设置(例如,通过自适应并发限制)。对于像 Hystrix 之类的东西有意义的情况,我们打算继续将 Hystrix 用于现有应用程序,并在新的内部项目中利用诸如elastic4j 之类的开放和活跃项目。我们开始建议其他人也这样做。

  当然,1.5.18版本还是可以在开发中用的,不过现在我们有了阿里巴巴的组件Sentinel


标签:hystrix,Hystrix,断路器,实例,Dashboard,监控
From: https://blog.51cto.com/u_15961549/6053849

相关文章

  • kubeadm部署安装+dashboard+harbor
    一、kubeadm部署1、环境准备12345678910111213141516171819202122232425262728293031323334353637383940414243444......
  • K8s:类似 dashboard 的K8s开源 Web/桌面 客户端工具 Headlamp
    写在前面分享一个k8s客户端开源项目Headlamp给小伙伴博文内容涉及:Headlamp桌面/集群Web端安装启动导入集群简单查看集群信息理解不足小伙伴帮忙指正<font......
  • TiDB集群安装TiDB Dashboard
    TiDBDashboard是从TiDB4.0版本起引入的可视化面板,用于帮助观察与诊断整个TiDB集群,详情参见 ​​TiDB文档-TiDBDashboard​​。本篇文章将介绍如何在Kubernetes......
  • springcloud(四) - 服务治理Hystrix
    功能介绍调用下游服务,下游因为超时、异常等原因报错的时候。hystrix保证不会出现整体异常,避免雪崩。主要策略是服务的熔断、降级 应用场景降级:异常、超时、熔断等情况......
  • React dashboard UI components library All In One
    ReactdashboardUIcomponentslibraryAllInOne仪表板UI组件库TremorTheReactlibrarytobuilddashboardsfast#beta⚠️$npminstall@tremor/react......
  • kubernetes-dashboard 实现 http 访问以及免 token 登录
    目录下载官方yaml文件修改yaml文件修改service端口修改clusterrolebinding修改deployment内容修改探针检测修改镜像拉取策略修改容器端口关闭token登录增加ing......
  • Grafana Dashboard
    GrafanaDashboardjvmmicrometer(4701)jmx_export(8563)https://grafana.com/grafana/dashboards/8563-jvm-dashboard/......
  • grafana 自定义dashboard Variables
    Variables 示例VariablesDependenciesdashboard显示  ......
  • 启用ceph dashboard及并通过prometheus 监控ceph集群状态
      cephdashboard  Dashboard介绍  Cephdashboard是通过一个web界面,对已经运行的ceph集群进行状态查看及功能配置等功能,早期ceph使用的是第三方的dashboa......
  • Openstack-dashboard默认配额
    创建实例不超过10个方法一修改配置文件在使用openstack的过程中,默认创建的实例最多10个,这是因为配额默认实例就是10所以我们需要修改配置文件/etc/nova/nova.conf中......