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
hystrix熔断器之配置的更多相关文章
- feign使用hystrix熔断的配置
熔断器hystrix 在分布式系统中,每个服务都可能会调用很多其他服务,被调用的那些服务就是依赖服务,有的时候某些依赖服务出现故障也是很正常的. Hystrix 可以让我们在分布式系统中对服务间的调用 ...
- hystrix熔断器之metrics
Metric概述 HystrixCommands和HystrixObservableCommands执行过程中,会产生执行的数据,这些数据对于观察调用的性能表现非常有用. 命令产生数据后,Metric ...
- hystrix熔断器之command实现
HystrixCommand是hystrix执行命令的具体实现,实现流程如下: 1.调用HystrixCommandExecutionHook的onStart方法 3.调用HystrixRequest ...
- hystrix熔断器之线程池
隔离 Hystrix有两种隔离方式:信号量和线程池. 线程池隔离:对每个command创建一个自己的线程池,执行调用.通过线程池隔离来保证不同调用不会相互干扰和每一个调用的并发限制. 信号量隔热:对每 ...
- hystrix熔断器之HystrixRequestLog
HystrixRequestLog会记录所有执行过的命令.
- SpringCloud系列七:Hystrix 熔断机制(Hystrix基本配置、服务降级、HystrixDashboard服务监控、Turbine聚合监控)
1.概念:Hystrix 熔断机制 2.具体内容 所谓的熔断机制和日常生活中见到电路保险丝是非常相似的,当出现了问题之后,保险丝会自动烧断,以保护我们的电器, 那么如果换到了程序之中呢? 当现在服务的 ...
- Hystrix 熔断机制
熔断机制相当于电路的跳闸功能,即在一定时间内,错误比例达到一定数目时业务从原来流程转移到另外的流程处理.在一段时间后,恢复到原业务逻辑. 测试代码如下 /** * @author zimu * @de ...
- 服务容错保护断路器Hystrix之五:配置
接着<服务容错保护断路器Hystrix之二:Hystrix工作流程解析>中的<2.8.关于配置>再列举重要的配置如下 一.hystrix在生产中的建议 1.保持timeout的 ...
- springcloud(六) Hystrix 熔断,限流
Hystrix 熔断: 首先仍然启动Eureka,这里就不说了. OrderController.java: package com.tuling.cloud.study.user.controlle ...
随机推荐
- graphics.h源代码下载
graphics.h源代码下载 /*graphics.h DefinitionsforGraphicsPackage. Copyright(c)BorlandInternational1987,198 ...
- C# 监听值的变化
1.写一个监听值变化的类 public class MonitorValueChange { private Visibility myValue; public Visibility MyValue ...
- kubeadm安装kubernetes(v18.8.8)
1. 前言 kubernetes版本更新迭代非常快,上一篇写kubernetes搭建时,版本还是v1.15.0,现在已经更新到v1.18.看kubernetes在github的官方仓库,8月14日小版 ...
- NumPy笔记-ndarray
ndarray,N维数组对象(矩阵) 所有元素必须是相同类型 ndim属性,维度个数 shape属性,各维度大小 dtype属性,数据类型 创建ndarray np.array(collection) ...
- C++奇淫技巧
一.关于:的妙用 如下代码 #include<cstdio> #include<iostream> typedef struct point{ int a; int b; po ...
- Hive 常见面试题(二)
1.Hive行转列和列转行如何实现? 行转列 使用 concat_ws 实现行转列. 例如: select user_id, concat_ws(',',collect_list(order_id)) ...
- 区块链入门到实战(36)之Solidity – 运算符
Solidity – 算术运算符 Solidity 支持的算术运算符,如下表所示: 假设变量A的值为10,变量B的值为20. 序号 运算符与描述 1 + (加)求和例: A + B = 30 2 – ...
- 给Django的Admin添加自定义Action 并移除需要选择对象的限制
不得不说,Django的Admin真的给开发带来很多便利,这不,我又来折腾了,这次是添加自定义的action 这个自定义的Action可以看看官方文档的介绍,很详细,不再赘述. https://doc ...
- HTTP/3 来了,你了解它么?
作为我们网上冲浪最为常见,也经常被人忽视的 HTTP 已经更新换代到了 HTTP/3.本文简单明了的带你认识 HTTP/3 的作用. 最近二狗子看到自己存储女神婷婷照片所用的云服务商--又拍云推出了 ...
- 力扣Leetcode 200. 岛屿数量
岛屿数量 给你一个由 '1'(陆地)和 '0'(水)组成的的二维网格,请你计算网格中岛屿的数量. 岛屿总是被水包围,并且每座岛屿只能由水平方向和/或竖直方向上相邻的陆地连接形成. 此外,你可以假设该网 ...