亲测可用!
一、failed and no fallback available
造成这种情况的原因
1.服务不可用
2.并发过大造成
二、timed-out and no fallback
造成这种情况的原因
服务连接正常,读取返回数据异常
改进:设置参数,feign 和hystrix,和ribbon的关系 参数
feign:
hystrix:
enabled: true
client:
config:
default:
connectTimeout: 40000
readTimeout: 40000
#hystrix的超时时间
hystrix:
command:
default:
execution:
timeout:
enabled: true
isolation:
thread:
timeoutInMilliseconds: 15000 #设置调用者等待命令执行的超时限制,超过此时间,HystrixCommand被标记为TIMEOUT,并执行回退逻辑
circuitBreaker:
requestVolumeThreshold: 200 #设置在一个滚动窗口中,打开断路器的最少请求数
sleepWindowInMilliseconds: 5000 #设置在回路被打开,拒绝请求到再次尝试请求并决定回路是否继续打开的时间
errorThresholdPercentage: 50 #设置打开回路并启动回退逻辑的错误比率
threadpool:
default:
coreSize: 200 #核心线程数
maxQueueSize: 200 #最大队列数
queueSizeRejectionThreshold: 160 #队列拒绝阈值设置
ribbon:
ReadTimeout: 10000
ConnectTimeout: 3000
MaxAutoRetries: 1 #同一台实例最大重试次数,不包括首次调用
MaxAutoRetriesNextServer: 1 #重试负载均衡其他的实例最大重试次数,不包括首次调用
OkToRetryOnAllOperations: false #是否所有操作都重试