1. 程式人生 > 實用技巧 >記Hystrix斷路器官方文件

記Hystrix斷路器官方文件

記Hystrix斷路器官方文件

斷路器CircuitBreaker執行流程

  1. 請求來臨時,判斷是否允許請求:通過判斷成功和失敗次數的比率與設定的threshold對比,如果大於那個值,就開啟斷路器。
  2. 當短路器開啟以後,這個服務將不會提供服務,知道sleep時間到了,到了之後,開始允許一部分請求訪問(實驗性訪問),此時為看開狀態。如果訪問通過,則關閉斷路器,同時清空執行緒池;若訪問沒有成功,則進入closed state。

Isolation

Hystrix employs the bulkhead pattern to isolate dependencies from each other and to limit concurrent access to any one of them.

Hystrix採用艙壁模式(bulkhead pattern)將依賴關係彼此隔離,並限制對其中的任何一個的併發訪問。

艙壁模式示意圖

Clients (libraries, network calls, etc) execute on separate threads. This isolates them from the calling thread (Tomcat thread pool) so that the caller may “walk away” from a dependency call that is taking too long.

客戶端(庫,網路呼叫等)在單獨的執行緒上執行。

這樣可以將它們與呼叫執行緒(Tomcat執行緒池)隔離,以便呼叫者可以“擺脫”花費太長時間的依賴項呼叫。