feign配置hystrix,和ribbon的各种超时配置
https://blog.csdn.net/zzzgd_666/article/details/83314833
https://www.cnblogs.com/yangxiaohui227/p/13031370.html
先记录一下
springcloud edg版本
1:feign底层是ribbon负载请求,所以默认读的是ribbon的超时配置(如果ribbon超时无效,去检查下feign是不是指定了url,指定url会走默认配置导致ribbon无效)
ribbon:
OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false,只对get请求重试,post要自己处理幂等
ReadTimeout: 10000 #负载均衡超时时间,默认值5000
ConnectTimeout: 2000 #ribbon请求连接的超时时间,默认值2000
MaxAutoRetries: 0 #对当前实例的重试次数,默认0
MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1
2:feign和ribbon同时存在的话feign的超时时间生效。
feign:
client:
config:
default:
connectTimeout: 1000
readTimeout: 8000
3:feign开启了hyxtrix(feignenabled =true)的时候,
timeoutInMilliseconds和ReadTimeout谁小谁生效
feign:
hystrix:
enabled: true
hystrix:
command:
default: #default全局有效,service id指定应用有效
execution:
timeout:
enabled: true #如果enabled设置为false,则请求超时交给ribbon控制,为true,则超时作为熔断根据
isolation:
thread:
timeoutInMilliseconds: 3000 #断路器超时时间,默认1000ms
4:hyxtrix的timeout:enabled设置false的时候超时就交给了ribbon控制,此时timeoutInMilliseconds无效
5:为了确保重试机制的正常运作,理论上(以实际情况为准)建议hystrix的超时时间为:(1 + MaxAutoRetries + MaxAutoRetriesNextServer) * ReadTimeout
还没有评论,来说两句吧...