feign配置hystrix,和ribbon的各种超时配置

清疚 2021-09-02 04:15 555阅读 0赞

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无效)

  1. ribbon:
  2. OkToRetryOnAllOperations: false #对所有操作请求都进行重试,默认false,只对get请求重试,post要自己处理幂等
  3. ReadTimeout: 10000 #负载均衡超时时间,默认值5000
  4. ConnectTimeout: 2000 #ribbon请求连接的超时时间,默认值2000
  5. MaxAutoRetries: 0 #对当前实例的重试次数,默认0
  6. MaxAutoRetriesNextServer: 1 #对切换实例的重试次数,默认1

2:feign和ribbon同时存在的话feign的超时时间生效。

  1. feign:
  2. client:
  3. config:
  4. default:
  5. connectTimeout: 1000
  6. readTimeout: 8000

3:feign开启了hyxtrix(feign:hyxtrix:enabled =true)的时候,timeoutInMilliseconds和ReadTimeout谁小谁生效

  1. feign:
  2. hystrix:
  3. enabled: true
  4. hystrix:
  5. command:
  6. default: #default全局有效,service id指定应用有效
  7. execution:
  8. timeout:
  9. enabled: true #如果enabled设置为false,则请求超时交给ribbon控制,为true,则超时作为熔断根据
  10. isolation:
  11. thread:
  12. timeoutInMilliseconds: 3000 #断路器超时时间,默认1000ms

4:hyxtrix的timeout:enabled设置false的时候超时就交给了ribbon控制,此时timeoutInMilliseconds无效

5:为了确保重试机制的正常运作,理论上(以实际情况为准)建议hystrix的超时时间为:(1 + MaxAutoRetries + MaxAutoRetriesNextServer) * ReadTimeout

发表评论

表情:
评论列表 (有 0 条评论,555人围观)

还没有评论,来说两句吧...

相关阅读