----------------------------------------------------
替换 URLConnection
----------------------------------------------------
feign 默认使用 jdk 原生的 URLConnection 发送请求, 没有连接池, 可用 apache 的 httpClient 替换, 通过设置连接池, 超时时间等对服务之间的调用优化
1.jar包导入
org.apache.httpcomponents/httpclient
com.netflix.feign/feign-httpclient
2.配置文件
feign.httpclient.enabled=true
----------------------------------------------------
----------------------------------------------------
hystrix 超时时间优化
解决首次请求失败的问题
----------------------------------------------------
hystrix 默认超时时间为 1s, 由于 ribbon 默认懒加载机制, 造成第一次请求容易超时
可以将 hystrix 超时加大为 5s
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=5000
或禁用 hystrix 超时时间
hystrix.command.default.execution.timeout.enabled=false
或使用 feign 时, 关闭 hystrix
feign.hystrix.enabled=false