Hystrix断路器
Hystrix,英文意思是豪猪,全身是刺,看起来就不好惹,是一种保护机制。Hystrix也是Netflix公司的一款组件。Hystix是Netflix开源的一个延迟和容错库,用于隔离访问远程服务、第三方库,防止出现级联失败。
Hystrix的几个重要概念
(1)服务降级:
服务器忙碌或者网络拥堵时,不让客户端等待并立刻返回一个友好提示,
相当于当程序运行异常时 给一个友善的回应 给程序降一级
(2)服务熔断
相当于一层保险 ,当服务访问量到最大时 相当于一个最后底线
(3)服务限流
到了一定程度 线程有序排队 限制进入
Hystrix案例
(1)创建新模块
(2)引入POM文件
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId