zoukankan      html  css  js  c++  java
  • hystrix熔断器之配置

    HystrixCommandProperties命令执行相关配置:

      hystrix.command.[commandkey].execution.isolation.strategy 隔离策略THREAD或SEMAPHORE 默认HystrixCommands使用THREAD方式 HystrixObservableCommands使用SEMAPHORE

      hystrix.command.[commandkey].execution.timeout.enabled 是否开启超时设置,默认true。

      hystrix.command.[commandkey].execution.isolation.thread.timeoutInMilliseconds 默认超时时间 默认1000ms

      hystrix.command.[commandkey].execution.isolation.thread.interruptOnTimeout是否打开超时线程中断 默认值true

      hystrix.command.[commandkey].execution.isolation.thread.interruptOnFutureCancel 当隔离策略为THREAD时,当执行线程执行超时时,是否进行中断处理,即Future#cancel(true)处理,默认为false。

      hystrix.command.[commandkey].execution.isolation.semaphore.maxConcurrentRequests 信号量最大并发度 默认值10该参数当使用ExecutionIsolationStrategy.SEMAPHORE策略时才有效。如果达到最大并发请求数,请求会被拒绝。理论上选择semaphore size的原则和选择thread size一致,但选用semaphore时每次执行的单元要比较小且执行速度快(ms级别),否则的话应该用thread。 

      hystrix.command.[commandkey].fallback.isolation.semaphore.maxConcurrentRequests fallback方法的信号量配置,配置getFallback方法并发请求的信号量,如果请求超过了并发信号量限制,则不再尝试调用getFallback方法,而是快速失败,默认信号量为10。

      hystrix.command.[commandkey].fallback.enabled 是否启用降级处理,如果启用了,则在超时或异常时调用getFallback进行降级处理,默认开启。

     

      hystrix.command.[commandkey].circuitBreaker.enabled 是否开启熔断机制,默认为true。

      hystrix.command.[commandkey].circuitBreaker.forceOpen 强制开启熔断,默认为false。

      hystrix.command.[commandkey].circuitBreaker.forceClosed 强制关闭熔断,默认为false。

      hystrix.command.[commandkey].circuitBreaker.sleepWindowInMilliseconds  熔断窗口时间,默认为5s。

      hystrix.command.[commandkey].circuitBreaker.requestVolumeThreshold 当在配置时间窗口内达到此数量后的失败,进行短路。默认20个

      hystrix.command.[commandkey].circuitBreaker.errorThresholdPercentage 出错百分比阈值,当达到此阈值后,开始短路。默认50%

      hystrix.command.[commandkey].metrics.rollingStats.timeInMilliseconds   设置统计滚动窗口的长度,以毫秒为单位。用于监控和熔断器 默认10s

      hystrix.command.[commandkey].metrics.rollingStats.numBuckets  设置统计窗口的桶数量 默认10

      hystrix.command.[commandkey].metrics.rollingPercentile.enabled 设置执行时间是否被跟踪,并且计算各个百分比,50%,90%等的时间 默认true

      hystrix.command.[commandkey].metrics.rollingPercentile.timeInMilliseconds 设置执行时间在滚动窗口中保留时间,用来计算百分比 默认60000ms

      hystrix.command.[commandkey].metrics.rollingPercentile.numBuckets 设置rollingPercentile窗口的桶数量 默认6。

      hystrix.command.[commandkey].metrics.rollingPercentile.bucketSize 此属性设置每个桶保存的执行时间的最大值 默认100。如果bucket size=100,window=10s,若这10s里有500次执行,只有最后100次执行会被统计到bucket里去。增加该值会增加内存开销以及排序的开销。

      hystrix.command.[commandkey].metrics.healthSnapshot.intervalInMilliseconds 记录health 快照(用来统计成功和错误绿)的间隔,默认500ms

     

      hystrix.command.[commandkey].requestCache.enabled 设置是否缓存请求,request-scope内缓存 默认值true

      hystrix.command.[commandkey].requestLog.enabled 设置HystrixCommand执行和事件是否打印到HystrixRequestLog中 默认值true

      hystrix.command.[commandkey].threadPoolKeyOverride   命令的线程池key,决定该命令使用哪个线程池。

    HystrixThreadPoolProperties线程池相关配置:

       hystrix.threadpool.[threadkey].coreSize 线程池核心线程数 默认值10;

      hystrix.threadpool.[threadkey].maximumSize  线程池最大线程数 默认值10; 

      hystrix.threadpool.[threadkey].allowMaximumSizeToDivergeFromCoreSize   当线程数大于核心线程数时,是否需要回收。与keepAliveTimeMinutes配合使用。

      hystrix.threadpool.[threadkey].keepAliveTimeMinutes  当实际线程数超过核心线程数时,线程存活时间 默认值1min

      hystrix.threadpool.[threadkey].maxQueueSize  最大等待队列数 默认不开启使用SynchronousQueue 不可动态调整

      hystrix.threadpool.[threadkey].queueSizeRejectionThreshold   允许在队列中的等待的任务数量 默认值5

      hystrix.threadpool.[threadkey].metrics.rollingStats.timeInMilliseconds 设置统计滚动窗口的长度,以毫秒为单位 默认值10000。

      hystrix.threadpool.[threadkey].metrics.rollingStats.numBuckets 设置统计窗口的桶数量 默认10

     HystrixCollapserProperties批处理相关配置:

      hystrix.collapser.[collapserKey].maxRequestsInBatch 单次批处理的最大请求数,达到该数量触发批处理,默认Integer.MAX_VALUE

      hystrix.collapser.[collapserKey].timerDelayInMilliseconds  触发批处理的延迟,也可以为创建批处理的时间+该值,默认值10

      hystrix.collapser.[collapserKey].requestCache.enabled 默认值true

      hystrix.collapser.[collapserKey].metrics.rollingStats.timeInMilliseconds  默认值10000

      hystrix.collapser.[collapserKey].metrics.rollingStats.numBuckets 默认值10

      hystrix.collapser.[collapserKey].metrics.rollingPercentile.enabled 默认值true

      hystrix.collapser.[collapserKey].metrics.rollingPercentile.timeInMilliseconds 默认值60000

      hystrix.collapser.[collapserKey].metrics.rollingPercentile.numBuckets 默认值6

      hystrix.collapser.[collapserKey].metrics.rollingPercentile.bucketSize 默认值100

  • 相关阅读:
    Centos 7 zabbix 实战应用
    Centos7 Zabbix添加主机、图形、触发器
    Centos7 Zabbix监控部署
    Centos7 Ntp 时间服务器
    Linux 150命令之查看文件及内容处理命令 cat tac less head tail cut
    Kickstart 安装centos7
    Centos7与Centos6的区别
    Linux 150命令之 文件和目录操作命令 chattr lsattr find
    Linux 发展史与vm安装linux centos 6.9
    Linux介绍
  • 原文地址:https://www.cnblogs.com/zhangwanhua/p/7742703.html
Copyright © 2011-2022 走看看