您的位置:首页 > 编程语言 > Java开发

feign + hystrix 监控和熔断测试(Spring Cloud)

2020-01-14 04:56 781 查看

1 修改sp09-feign项目

1) pom.xml 添加 hystrix 起步依赖

feign 没有包含完整的 hystrix 依赖
右键点击项目,编辑起步依赖,添加hystrix依赖

2) 主程序添加 @EnableCircuitBreaker

3) sp09-feign 配置 actuator,暴露 hystrix.stream 监控端点 actuator 依赖

查看pom.xml, 确认已经添加了 actuator 依赖

4) application.yml 暴露 hystrix.stream 端点

5) 启动服务,查看监控端点

http://localhost:3001/actuator

6) hystrix dashboard

启动 hystrix dashboard 服务,填入 feign 监控路径,开启监控
访问 http://localhost:4001/hystrix

填入 feign 监控路径:
http://localhost:3001/actuator/hystrix.stream

访问微服务,以产生监控数据

http://localhost:3001/item-service/35

http://localhost:3001/user-service/7
http://localhost:3001/user-service/7/score?score=100

http://localhost:3001/order-service/123abc
http://localhost:3001/order-service/

2 熔断测试

1) 用 ab 工具,以并发50次,来发送20000个请求

2) 断路器状态为 Open,所有请求会被短路,直接降级执行 fallback 方法

  • 点赞
  • 收藏
  • 分享
  • 文章举报
Cv小码农 发布了117 篇原创文章 · 获赞 1 · 访问量 482 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: