網關的超時層級
zuul
zuul: max: host: connections: 500 host: socket-timeout-millis: 60000 connect-timeout-millis: 60000
ribbon
ribbon: ReadTimeout: 10000 ConnectTimeout: 10000 MaxAutoRetries: 0 MaxAutoRetriesNextServer: 1 eureka: enabled: true
hystrix
hystrix: command: default: execution: timeout: enabled: true isolation: thread: timeoutInMilliseconds: 60000
小結
走網關的話,有三層的超時時間,一個是zuul的,一個是ribbon的,還有一個是hystrix的。hystrix的超時設置,AbstractRibbonCommand這個類沒有暴露設置hystrix的Setter方法出來,所以無法通過繼承的方式來擴展。因此要自定義ribbon超時的話,需要這個超時時間是小於hystrix的,不然就提前被hystrix超時了,無法起到效果。
