Spring Cloud搭建微服务架构----断路器

保证服务稳定的手段:

  • 重试机制;
  • 限流;
  • 熔断机制;
  • 负载均衡;
  • 降级(本地缓存);

Hystrix的调用保护

Hystrix经过一个回调函数保护服务调用。git

@Component
public class StoreIntegration {

    @HystrixCommand(fallbackMethod = "defaultStores")
    public Object getStores(Map<String, Object> parameters) {
        //do stuff that might fail
    }

    public Object defaultStores(Map<String, Object> parameters) {
        return /* something useful */;
    }
}

Hystrix Dashboard

为了有效监控服务调用状态,可经过Hystrix Dashboard进行服务状态监控。github

代码

Hystrix Dashboardspring

相关文章
相关标签/搜索