hystrix配置yaml
时间: 2023-07-04 21:21:49 浏览: 66
以下是一个示例Hystrix的配置yaml文件:
```yaml
hystrix:
command:
default:
execution:
timeout:
enabled: true
duration: 5000
# 以下是fallback调用的线程池配置
isolation:
thread:
timeoutInMilliseconds: 10000
circuitBreaker:
enabled: true
requestVolumeThreshold: 20
sleepWindowInMilliseconds: 5000
errorThresholdPercentage: 50
threadpool:
default:
coreSize: 10
maximumSize: 100
maxQueueSize: -1
queueSizeRejectionThreshold: 5
```
解释一下上述配置:
- `hystrix.command.default.execution.timeout.enabled`:开启Hystrix的超时机制。
- `hystrix.command.default.execution.timeout.duration`:设置Hystrix的超时时间为5秒。
- `hystrix.command.default.isolation.thread.timeoutInMilliseconds`:设置Hystrix的隔离策略为线程隔离,并设置超时时间为10秒。
- `hystrix.command.default.circuitBreaker.enabled`:开启Hystrix的熔断器。
- `hystrix.command.default.circuitBreaker.requestVolumeThreshold`:设置在一个统计窗口内熔断的最小请求数,这里为20。
- `hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds`:当断路器打开后,经过该时间窗口后会进入半开状态,尝试放行一次请求,这里为5秒。
- `hystrix.command.default.circuitBreaker.errorThresholdPercentage`:触发熔断的错误百分比,这里为50%。
- `hystrix.threadpool.default.coreSize`:设置线程池的核心线程数为10。
- `hystrix.threadpool.default.maximumSize`:设置线程池的最大线程数为100。
- `hystrix.threadpool.default.maxQueueSize`:设置线程池的最大队列大小为-1,表示使用SynchronousQueue作为队列。
- `hystrix.threadpool.default.queueSizeRejectionThreshold`:设置线程池的拒绝阈值为5,当队列大小达到该阈值时,新的任务会被拒绝。
以上只是一个示例配置,您可以根据自己的应用程序需要进行相应的调整。