一、hystrix简介
1. hystrix是什么?
- hystrix是一个熔断器组件,目前已经处于维护状态
- 它设计用来当分布式系统发生不可避免的异常的时候去隔离当前服务和远程服务、系统、三方包的联系,防止出现级联失败的情况,从而导致整个系统奔溃
2. hystrix文档
- wiki介绍:github.com/Netflix/Hys…
- API介绍:netflix.github.io/Hystrix/jav…
3. hystrix主要功能有哪些
3.1 延迟和容错
- 无级联失败;失败转移和优雅降级;快速失败和恢复
- 失败时基于线程和信号量的断路器隔离
3.2 实时响应
- 实时监控并更改相关配置,例如触发熔断机制等
- 秒级别的触发报警、作出决定以及查看结果
3.3 并发
- 并发执行
4. Hello World
- 采用api方式编程
- 更多的使用方式参见:github.com/Netflix/Hys…
public class CommandHelloWorld extends HystrixCommand<String> {
private final String name;
public CommandHelloWorld(String name) {
super(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"));
this.name = name;
}
@Override
protected String run() {
return "Hello " + name + "!";
}
}
String s = new CommandHelloWorld("Bob").execute();
Future<String> s = new CommandHelloWorld("Bob").queue();
Observable<String> s = new CommandHelloWorld("Bob").observe();
5. Dashboard
- hystrix工程中的dashboard已经废弃了,现在迁移到:github.com/Netflix-Sku…
- hystrix的stream配置:github.com/Netflix/Hys…