背景
我使用Spring雲Brixton.RC2,Zuul和Eureka。Zuul/Ribbon/Hystrix不在不同的實例上重試
我有一個網關服務@EnableZuulProxy
和book-service
與status
方法。通過配置,我可以通過睡眠定義的時間模擬status
方法的工作。
的Zuul路線簡單
zuul.routes.foos.path=/foos/**
zuul.routes.foos.serviceId=reservation-service
我運行book-service
的兩個實例。當我將睡眠時間設置在Hystrix超時閾值(1000毫秒)以下時,我可以看到請求轉到兩個圖書服務的實例。這很好。
問題
我明白,如果蝟命令失敗,它應該是可能的絲帶到不同的服務器上試該命令。這應該會讓客戶失敗。
我讀功能區的配置,並增加在Zuul以下配置:
zuul.routes.reservation-service.retryable=true //not sure which one to try
zuul.routes.foos.retryable=true //not sure which one to try
ribbon.MaxAutoRetries=0 // I don't want to retry on the same host, I also tried with 1 it doesn't work either
ribbon.MaxAutoRetriesNextServer=2
ribbon.OkToRetryOnAllOperations=true
現在這樣只有一個服務睡覺時間超過1s,這意味着我有一個健康的服務,我更新配置,並一個壞的。
當我打電話網關的電話獲得發送到這兩種情況下,一半的呼叫返回一個500。我看到了豪豬超時網關:
com.netflix.zuul.exception.ZuulException: Forwarding error
[...]
Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: reservation-service timed-out and no fallback available.
[...]
Caused by: java.util.concurrent.TimeoutException: null
爲什麼不絲帶重試調用另一個實例?
我在這裏想念什麼?
參考
- 涉及到這個question(未解決)
- Ribbon configuration
- 根據這一commit Zuul應該支持重試功能區
我已經加入 '重:超時的絲帶,它會與500ms的服務
下面你有我在zuul情況下得到了數重試servation-service.ribbon.ConnectTimeout = 250 預約service.ribbon.OkToRetryOnAllOperations =真 預約service.ribbon.MaxAutoRetriesNextServer = 2 預約service.ribbon.MaxAutoRetries = 0' 到我的配置,但我怕沒有解決問題。 – phoenix7360
太棒了!我還沒有意識到,絲帶重試發生在同一個Hystrix命令內。我認爲每次重試都會有他們自己的Hystrix命令。這樣做更有意義。 – phoenix7360