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

相關文章
相關標籤/搜索