Hystrix完整配置列表

前提
Hystrix在2018年11月20日之后已经停止维护,最后一个提交记录是:Latest commit 3cb2158 on 20 Nov 2018,最后一个正式版本为1.5.18。鉴于目前所在公司的技术栈是Spring Cloud,熔断和降级组件主要用的还是Hystrix,这里就Hystrix的完整列表做一个分析记录,方便以后可以随时查询。本文主要参考:Hystrix Configuration。其中,命令配置是针对HystrixCommand,主要包括命令执行(execution)配置、命令降级(fallback)配置、熔断器(circuit breaker)配置、度量统计(metrics)配置和请求上下文配置。
HystrixCommandKey、HystrixCommandGroupKey和HystrixThreadPoolKey
HystrixCommandKey、HystrixCommandGroupKey和HystrixThreadPoolKey三个KEY是HystrixCommand的重要标识。下面分别分析一下它们的含义。
HystrixCommandKey
HystrixCommandKey是Hystrix命令的唯一标识,准确来说是HystrixCommand实例或者HystrixObservableCommand实例的唯一标识。它是必须的,如果不自定义配置,它会通过下面方式确定默认值:
[HystrixCommand或者HystrixObservableCommand的具体子类].getClass().getSimpleName();
编程式配置如下:
HystrixCommandKey.Factory.asKey("Your Key");
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Group Key"))
.andCommandKey(HystrixCommandKey.Factory.asKey("Command Key")));
}
注意一点:大部分Hystrix的配置都是和HystrixCommandKey绑定,所以HystrixCommandKey是比较重要的。
HystrixCommandGroupKey
HystrixCommandGroupKey是用于对Hystrix命令进行分组,分组之后便于统计展示于仪表盘、上传报告和预警等等,也就是说,HystrixCommandGroupKey是Hystrix内部进行度量统计时候的分组标识,数据上报和统计的最小维度就是分组的KEY。HystrixCommandGroupKey是必须配置的,配置方式如下:
HystrixCommandGroupKey.Factory.asKey("Group Key")
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("Group Key")));
}
HystrixThreadPoolKey
HystrixThreadPoolKey主要标识用于监控、度量和缓存等等作用的HystrixThreadPool实例。一个HystrixCommand会和一个独立的HystrixThreadPool实例关联,也就是说一类HystrixCommand总是在同一个HystrixThreadPool实例中执行。如果不显式配置HystrixThreadPoolKey,那么会使用HystrixCommandGroupKey的值去配置HystrixThreadPoolKey。HystrixThreadPoolKey的配置方式如下:
HystrixThreadPoolKey.Factory.asKey("ThreadPoolKey")
public Command() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("xxx"))
.andCommandKey(HystrixCommandKey.Factory.asKey("YYY"))
.andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey("ThreadPoolKey")));
}
命令执行(execution)配置
隔离策略
- execution.isolation.strategy
隔离策略决定Hystrix命令执行的时候采用什么类型的策略进行依赖隔离。
| 项 | 值 |
|---|---|
| 默认值 | THREAD (见ExecutionIsolationStrategy.THREAD) |
| 可选值 | THREAD,SEMAPHORE |
| 默认全局配置 | hystrix.command.default.execution.isolation.strategy |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.isolation.strategy |
执行隔离策略到底选择线程池(THREAD)还是信号量(SEMAPHORE)?文档中给出的建议是:
使用
HystrixCommand的时候建议用THREAD策略,使用HystrixObservableCommand的时候建议使用SEMAPHORE策略。
使用
THREAD策略让HystrixCommand在线程中执行可以提供额外的保护层,以防止因为网络超时导致的延时失败。
一般情况下,只有这种特殊例子下
HystrixCommand会搭配SEMAPHORE策略使用:调用的频次太高(例如每个实例每秒数百次调用),这种情况如果选用THREAD策略有可能导致超过线程隔离的上限(有可能需要太多的线程或者命令太多线程不足够用于隔离请求),这种情况一般是非网络请求调用。
笔者想说的是:建议选用默认值,因为目前很少遇到使用信号量隔离的场景。
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.THREAD)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.strategy=THREAD
# 实例配置
hystrix.command.CustomCommand.execution.isolation.strategy=THREAD
是否允许超时
- execution.timeout.enabled
决定HystrixCommand#run()执行时是否允许超时,只有设置为true的时候,下面提到的“超时时间上限”才会有效。
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true,false |
| 默认全局配置 | hystrix.command.default.execution.timeout.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.timeout.enabled |
| 建议(笔者备注) | 保持选用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.timeout.enabled=true
# 实例配置
hystrix.command.CustomCommand.execution.timeout.enabled=true
超时时间上限
- execution.isolation.thread.timeoutInMilliseconds
HystrixCommand执行时候超时的最大上限,单位是毫秒,如果命令执行耗时超过此时间值那么会进入降级逻辑。这个配置生效的前提是hystrix.command.default.execution.timeout.enabled或者hystrix.command.[HystrixCommandKey].execution.timeout.enabled为true。
| 项 | 值 |
|---|---|
| 默认值 | 1000 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.isolation.thread.timeoutInMilliseconds |
| 建议(笔者备注) | 保持选用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionTimeoutInMilliseconds(1000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=1000
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.timeoutInMilliseconds=1000
超时是否中断
此配置项决定HystrixCommand#run()执行的时候调用超时的情况下是否中断。
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true、false |
| 默认全局配置 | hystrix.command.default.execution.isolation.thread.interruptOnTimeout |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.isolation.thread.interruptOnTimeout |
| 建议(笔者备注) | 保持选用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationThreadInterruptOnTimeout(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.interruptOnTimeout=true
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.interruptOnTimeout=true
取消是否中断
- execution.isolation.thread.interruptOnCancel
此配置项决定HystrixCommand#run()执行的时候取消调用的情况下是否中断。
| 项 | 值 |
|---|---|
| 默认值 | false |
| 可选值 | true、false |
| 默认全局配置 | hystrix.command.default.execution.isolation.thread.interruptOnCancel |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.isolation.thread.interruptOnCancel |
| 建议(笔者备注) | 保持选用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationThreadInterruptOnFutureCancel(false)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.thread.interruptOnCancel=false
# 实例配置
hystrix.command.CustomCommand.execution.isolation.thread.interruptOnCancel=false
最大并发请求上限(SEMAPHORE)
- execution.isolation.semaphore.maxConcurrentRequests
此配置项决定使用HystrixCommand#run()方法和ExecutionIsolationStrategy.SEMAPHORE隔离策略下并发请求数量的最高上限。
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests |
| 实例配置 | hystrix.command.[HystrixCommandKey].execution.isolation.semaphore.maxConcurrentRequests |
| 建议(笔者备注) | 必须根据实际情况设定此值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.execution.isolation.semaphore.maxConcurrentRequests=100
# 实例配置
hystrix.command.CustomCommand.execution.isolation.semaphore.maxConcurrentRequests=100
命令降级(fallback)配置
命令降级配置控制HystrixCommand#getFallback()的执行逻辑,所有命令降级配置对策略ExecutionIsolationStrategy.THREAD或者ExecutionIsolationStrategy.SEMAPHORE都生效。
最大并发降级请求处理上限
- fallback.isolation.semaphore.maxConcurrentRequests
这个属性用于控制一个HystrixCommand#getFallback()实例方法在执行线程中调用的最大上限,如果超过此上限,降级逻辑不会执行并且会抛出一个异常。
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.fallback.isolation.semaphore.maxConcurrentRequests |
| 实例配置 | hystrix.command.[HystrixCommandKey].fallback.isolation.semaphore.maxConcurrentRequests |
| 建议(笔者备注) | 必须根据实际情况设定此值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withFallbackIsolationSemaphoreMaxConcurrentRequests(20)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.fallback.isolation.semaphore.maxConcurrentRequests=20
# 实例配置
hystrix.command.CustomCommand.fallback.isolation.semaphore.maxConcurrentRequests=20
是否开启降级
- fallback.enabled
此属性控制当HystrixCommand执行失败之后是否调用HystrixCommand#getFallback()。
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | false、true |
| 默认全局配置 | hystrix.command.default.fallback.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].fallback.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withFallbackEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.fallback.enabled=true
# 实例配置
hystrix.command.CustomCommand.fallback.enabled=true
断路器(circuit breaker)配置
断路器配置用于控制HystrixCircuitBreaker实例的行为。
是否启用断路器
- circuitBreaker.enabled
此属性确定断路器是否用于跟踪健康状况,以及当断路器打开的时候是否用于短路请求(使请求快速失败进入降级逻辑)。
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | false、true |
| 默认全局配置 | hystrix.command.default.circuitBreaker.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.enabled=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.enabled=true
断路器请求量阈值
- circuitBreaker.requestVolumeThreshold
此属性设置将使断路器打开的滑动窗口中的最小请求数量。
例如,如果值是20,那么如果在滑动窗口中只接收到19个请求(比如一个10秒的窗口),即使所有19个请求都失败了,断路器也不会打开。
| 项 | 值 |
|---|---|
| 默认值 | 20 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.circuitBreaker.requestVolumeThreshold |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.requestVolumeThreshold |
| 建议(笔者备注) | 建议保持默认值,如果部分接口不能容忍默认阈值可以单独配置 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerRequestVolumeThreshold(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.requestVolumeThreshold=10
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.requestVolumeThreshold=10
断路器等待窗口时间
- circuitBreaker.sleepWindowInMilliseconds
此属性设置断路器打开后拒绝请求的时间量,每隔一段时间(sleepWindowInMilliseconds,单位是毫秒)允许再次尝试(也就是放行一个请求)确定是否应该关闭断路器。
| 项 | 值 |
|---|---|
| 默认值 | 5000 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.sleepWindowInMilliseconds |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerSleepWindowInMilliseconds(5000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.sleepWindowInMilliseconds=5000
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.sleepWindowInMilliseconds=5000
断路器错误百分比阈值
- circuitBreaker.errorThresholdPercentage
此属性设置一个错误百分比,当请求错误率超过设定值,断路器就会打开。
| 项 | 值 |
|---|---|
| 默认值 | 50 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.circuitBreaker.errorThresholdPercentage |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.errorThresholdPercentage |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerErrorThresholdPercentage(50)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.errorThresholdPercentage=50
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.errorThresholdPercentage=50
注意:
- 配置项
circuitBreaker.requestVolumeThreshold针对错误请求数量。 - 配置项
circuitBreaker.errorThresholdPercentage针对错误请求百分比。
是否强制打开断路器
- circuitBreaker.forceOpen
此属性控制断路器是否强制打开,强制打开断路器会使所有请求直接进入降级逻辑,也就是包裹在HystrixCommand#run()的逻辑不会执行。circuitBreaker.forceOpen属性和circuitBreaker.forceClosed属性互斥。
| 项 | 值 |
|---|---|
| 默认值 | false |
| 可选值 | false、true |
| 默认全局配置 | hystrix.command.default.circuitBreaker.forceOpen |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.forceOpen |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerForceOpen(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.forceOpen=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.forceOpen=true
是否强制关闭断路器
- circuitBreaker.forceClosed
此属性控制断路器是否强制关闭,强制关闭断路器会导致所有和断路器相关的配置和功能都失效,HystrixCommand#run()抛出异常会正常进入降级逻辑。circuitBreaker.forceClosed属性和circuitBreaker.forceOpen属性互斥。
| 项 | 值 |
|---|---|
| 默认值 | false |
| 可选值 | false、true |
| 默认全局配置 | hystrix.command.default.circuitBreaker.forceClosed |
| 实例配置 | hystrix.command.[HystrixCommandKey].circuitBreaker.forceClosed |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerForceClosed(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.circuitBreaker.forceClosed=true
# 实例配置
hystrix.command.CustomCommand.circuitBreaker.forceClosed=true
度量统计(metrics)配置
度量统计配置会对HystrixCommand或者HystrixObservableCommand执行时候的统计数据收集动作生效。
滑动窗口持续时间
- metrics.rollingStats.timeInMilliseconds
| 项 | 值 |
|---|---|
| 默认值 | 10000 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.metrics.rollingStats.timeInMilliseconds |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingStats.timeInMilliseconds |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingStatisticalWindowInMilliseconds(10000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingStats.timeInMilliseconds=10000
# 实例配置
hystrix.command.CustomCommand.metrics.rollingStats.timeInMilliseconds=10000
滑动窗口Bucket总数
- metrics.rollingStats.numBuckets
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | 需要满足metrics.rollingStats.timeInMilliseconds % metrics.rollingStats.numBuckets == 0,要尽量小,否则有可能影响性能 |
| 默认全局配置 | hystrix.command.default.metrics.rollingStats.numBuckets |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingStats.numBuckets |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingStatisticalWindowBuckets(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingStats.numBuckets=10
# 实例配置
hystrix.command.CustomCommand.metrics.rollingStats.numBuckets=10
是否启用百分数计算
- metrics.rollingPercentile.enabled
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true、false |
| 默认全局配置 | hystrix.command.default.metrics.rollingPercentile.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingPercentile.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingPercentileEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingPercentile.enabled=true
# 实例配置
hystrix.command.CustomCommand.metrics.rollingPercentile.enabled=true
百分数计算使用的滑动窗口持续时间
- metrics.rollingPercentile.timeInMilliseconds
| 项 | 值 |
|---|---|
| 默认值 | 60000 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.metrics.rollingPercentile.timeInMilliseconds |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingPercentile.timeInMilliseconds |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingPercentileWindowInMilliseconds(60000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingPercentile.timeInMilliseconds=60000
# 实例配置
hystrix.command.CustomCommand.metrics.rollingPercentile.timeInMilliseconds=60000
百分数计算使用的Bucket总数
- metrics.rollingPercentile.numBuckets
| 项 | 值 |
|---|---|
| 默认值 | 6 |
| 可选值 | 满足metrics.rollingPercentile.timeInMilliseconds % metrics.rollingPercentile.numBuckets == 0,要尽量小,否则有可能影响性能 |
| 默认全局配置 | hystrix.command.default.metrics.rollingPercentile.numBuckets |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingPercentile.numBuckets |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingPercentileWindowBuckets(6)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingPercentile.numBuckets=6
# 实例配置
hystrix.command.CustomCommand.metrics.rollingPercentile.numBuckets=6
百分数计算使用的Bucket容量
- metrics.rollingPercentile.bucketSize
| 项 | 值 |
|---|---|
| 默认值 | 100 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.metrics.rollingPercentile.bucketSize |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.rollingPercentile.bucketSize |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsRollingPercentileBucketSize(100)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.rollingPercentile.bucketSize=100
# 实例配置
hystrix.command.CustomCommand.metrics.rollingPercentile.bucketSize=100
健康状态快照收集的周期
- metrics.healthSnapshot.intervalInMilliseconds
| 项 | 值 |
|---|---|
| 默认值 | 500 |
| 可选值 | - |
| 默认全局配置 | hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds |
| 实例配置 | hystrix.command.[HystrixCommandKey].metrics.healthSnapshot.intervalInMilliseconds |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withMetricsHealthSnapshotIntervalInMilliseconds(500)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.metrics.healthSnapshot.intervalInMilliseconds=500
# 实例配置
hystrix.command.CustomCommand.metrics.healthSnapshot.intervalInMilliseconds=500
请求上下文配置
请求上下文属性主要涉及到HystrixRequestContext和HystrixCommand的使用。
是否启用请求缓存
- requestCache.enabled
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true、false |
| 默认全局配置 | hystrix.command.default.requestCache.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].requestCache.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withRequestCacheEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.requestCache.enabled=true
# 实例配置
hystrix.command.CustomCommand.requestCache.enabled=true
是否启用请求日志
- requestLog.enabled
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true、false |
| 默认全局配置 | hystrix.command.default.requestLog.enabled |
| 实例配置 | hystrix.command.[HystrixCommandKey].requestLog.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withRequestLogEnabled(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.command.default.requestLog.enabled=true
# 实例配置
hystrix.command.CustomCommand.requestLog.enabled=true
请求合成器配置
请求合成器配置主要控制HystrixCollapser的行为。
请求合成的最大批次量
- maxRequestsInBatch
| 项 | 值 |
|---|---|
| 默认值 | Integer.MAX_VALUE |
| 可选值 | - |
| 默认全局配置 | hystrix.collapser.default.maxRequestsInBatch |
| 实例配置 | hystrix.collapser.[HystrixCollapserKey].maxRequestsInBatch |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>, String, String> {
public CustomHystrixCollapser(Setter setter) {
super(Setter.withCollapserKey(HystrixCollapserKey.Factory.asKey("CustomHystrixCollapser"))
.andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter()
.withMaxRequestsInBatch(10)));
}
@Override
public String getRequestArgument() {
return null;
}
@Override
protected HystrixCommand<List<String>> createCommand(Collection<CollapsedRequest<String, String>> collapsedRequests) {
return null;
}
@Override
protected void mapResponseToRequests(List<String> batchResponse, Collection<CollapsedRequest<String, String>> collapsedRequests) {
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.maxRequestsInBatch=10
# 实例配置
hystrix.collapser.CustomHystrixCollapser.maxRequestsInBatch=10
延迟执行时间
- timerDelayInMilliseconds
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | - |
| 默认全局配置 | hystrix.collapser.default.timerDelayInMilliseconds |
| 实例配置 | hystrix.collapser.[HystrixCollapserKey].timerDelayInMilliseconds |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>, String, String> {
public CustomHystrixCollapser(Setter setter) {
super(Setter.withCollapserKey(HystrixCollapserKey.Factory.asKey("CustomHystrixCollapser"))
.andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter()
.withTimerDelayInMilliseconds(10)));
}
@Override
public String getRequestArgument() {
return null;
}
@Override
protected HystrixCommand<List<String>> createCommand(Collection<CollapsedRequest<String, String>> collapsedRequests) {
return null;
}
@Override
protected void mapResponseToRequests(List<String> batchResponse, Collection<CollapsedRequest<String, String>> collapsedRequests) {
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.timerDelayInMilliseconds=10
# 实例配置
hystrix.collapser.CustomHystrixCollapser.timerDelayInMilliseconds=10
是否启用请求合成缓存
- requestCache.enabled
| 项 | 值 |
|---|---|
| 默认值 | true |
| 可选值 | true、false |
| 默认全局配置 | hystrix.collapser.default.requestCache.enabled |
| 实例配置 | hystrix.collapser.[HystrixCollapserKey].requestCache.enabled |
| 建议(笔者备注) | 建议保持默认值 |
编程式配置:
public class CustomHystrixCollapser extends HystrixCollapser<List<String>, String, String> {
public CustomHystrixCollapser(Setter setter) {
super(Setter.withCollapserKey(HystrixCollapserKey.Factory.asKey("CustomHystrixCollapser"))
.andCollapserPropertiesDefaults(HystrixCollapserProperties.Setter()
.withTimerDelayInMilliseconds(10)));
}
@Override
public String getRequestArgument() {
return null;
}
@Override
protected HystrixCommand<List<String>> createCommand(Collection<CollapsedRequest<String, String>> collapsedRequests) {
return null;
}
@Override
protected void mapResponseToRequests(List<String> batchResponse, Collection<CollapsedRequest<String, String>> collapsedRequests) {
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.collapser.default.requestCache.enabled=true
# 实例配置
hystrix.collapser.CustomHystrixCollapser.requestCache.enabled=true
线程池配置
Hystrix使用的是JUC线程池ThreadPoolExecutor,线程池相关配置直接影响ThreadPoolExecutor实例。Hystrix的命令执行选用了线程池策略,那么就是通过线程池隔离执行的,最好为每一个分组设立独立的线程池。笔者在生产实践的时候,一般把HystrixCommandGroupKey和HystrixThreadPoolKey设置为一致。
核心线程数
- coreSize
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | - |
| 默认全局配置 | hystrix.threadpool.default.coreSize |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].coreSize |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withCoreSize(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.coreSize=10
# 实例配置
hystrix.threadpool.CustomCommand.coreSize=10
最大线程数
- maximumSize
此属性只有在allowMaximumSizeToDivergeFromCoreSize为true的时候才生效。
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | - |
| 默认全局配置 | hystrix.threadpool.default.maximumSize |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].maximumSize |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMaximumSize(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.maximumSize=10
# 实例配置
hystrix.threadpool.CustomCommand.maximumSize=10
最大任务队列容量
- maxQueueSize
此属性配置为-1时使用的是SynchronousQueue,配置为大于1的整数时使用的是LinkedBlockingQueue。
| 项 | 值 |
|---|---|
| 默认值 | -1 |
| 可选值 | -1或者大于0的整数 |
| 默认全局配置 | hystrix.threadpool.default.maxQueueSize |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].maxQueueSize |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMaxQueueSize(-1)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.maxQueueSize=-1
# 实例配置
hystrix.threadpool.CustomCommand.maxQueueSize=-1
任务拒绝的任务队列阈值
- queueSizeRejectionThreshold
当maxQueueSize配置为-1的时候,此配置项不生效。
| 项 | 值 |
|---|---|
| 默认值 | 5 |
| 可选值 | 大于0的整数 |
| 默认全局配置 | hystrix.threadpool.default.queueSizeRejectionThreshold |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].queueSizeRejectionThreshold |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withQueueSizeRejectionThreshold(5)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.queueSizeRejectionThreshold=5
# 实例配置
hystrix.threadpool.CustomCommand.queueSizeRejectionThreshold=5
非核心线程存活时间
- keepAliveTimeMinutes
当allowMaximumSizeToDivergeFromCoreSize为true并且maximumSize大于coreSize时此配置才生效。
| 项 | 值 |
|---|---|
| 默认值 | 1 |
| 可选值 | 大于0的整数 |
| 默认全局配置 | hystrix.threadpool.default.keepAliveTimeMinutes |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].keepAliveTimeMinutes |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withKeepAliveTimeMinutes(1)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.keepAliveTimeMinutes=1
# 实例配置
hystrix.threadpool.CustomCommand.keepAliveTimeMinutes=1
是否允许最大线程数生效
- allowMaximumSizeToDivergeFromCoreSize
| 项 | 值 |
|---|---|
| 默认值 | false |
| 可选值 | true、false |
| 默认全局配置 | hystrix.threadpool.default.allowMaximumSizeToDivergeFromCoreSize |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].allowMaximumSizeToDivergeFromCoreSize |
| 建议(笔者备注) | 根据真实情况自行配置和调整 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withAllowMaximumSizeToDivergeFromCoreSize(true)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.allowMaximumSizeToDivergeFromCoreSize=true
# 实例配置
hystrix.threadpool.CustomCommand.allowMaximumSizeToDivergeFromCoreSize=true
线程池滑动窗口持续时间
- metrics.rollingStats.timeInMilliseconds
| 项 | 值 |
|---|---|
| 默认值 | 10000 |
| 可选值 | - |
| 默认全局配置 | hystrix.threadpool.default.metrics.rollingStats.timeInMilliseconds |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].metrics.rollingStats.timeInMilliseconds |
| 建议(笔者备注) | 建议使用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMetricsRollingStatisticalWindowInMilliseconds(10000)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.metrics.rollingStats.timeInMilliseconds=10000
# 实例配置
hystrix.threadpool.CustomCommand.metrics.rollingStats.timeInMilliseconds=10000
线程池滑动窗口Bucket总数
- metrics.rollingStats.numBuckets
| 项 | 值 |
|---|---|
| 默认值 | 10 |
| 可选值 | 满足metrics.rollingStats.timeInMilliseconds % metrics.rollingStats.numBuckets == 0,值要尽量少,否则会影响性能 |
| 默认全局配置 | hystrix.threadpool.default.metrics.rollingStats.numBuckets |
| 实例配置 | hystrix.threadpool.[HystrixThreadPoolKey].metrics.rollingStats.numBuckets |
| 建议(笔者备注) | 建议使用默认值 |
编程式配置:
public class CustomCommand extends HystrixCommand<String> {
public CustomCommand() {
super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("CustomCommand"))
.andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter()
.withMetricsRollingStatisticalWindowBuckets(10)));
}
@Override
protected String run() throws Exception {
return null;
}
}
配置文件中(Properties)配置:
# 下面配置二选一
# 默认全局配置
hystrix.threadpool.default.metrics.rollingStats.numBuckets=10
# 实例配置
hystrix.threadpool.CustomCommand.metrics.rollingStats.numBuckets=10
原文链接
- Github Page:http://throwable.club/2019/05/29/framework-hystrix-full-configuration
- Coding Page:http://throwable.coding.me/2019/05/29/framework-hystrix-full-configuration
(本文完 e-a-201890602 1:00 AM c-3-d)
Hystrix完整配置列表的更多相关文章
- SpringCloud系列七:Hystrix 熔断机制(Hystrix基本配置、服务降级、HystrixDashboard服务监控、Turbine聚合监控)
1.概念:Hystrix 熔断机制 2.具体内容 所谓的熔断机制和日常生活中见到电路保险丝是非常相似的,当出现了问题之后,保险丝会自动烧断,以保护我们的电器, 那么如果换到了程序之中呢? 当现在服务的 ...
- [Nginx]Nginx的基本配置与优化1(完整配置示例与虚拟主机配置)
---------------------------------------------------------------------------------------- 完整配置示例: [ n ...
- [转载]Mybatis Generator最完整配置详解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- thinkphp 完整配置config.php
ThinkPHP的系统配置都采用数组形式,配置文件地址:Bin/Conf/config.php CHECK_FILE_CASE -- windows环境下面的严格检查大小写. /* 项目设定 ...
- 夺命雷公狗ThinkPHP项目之----企业网站18之网站配置列表页的完成
我们点击下配置列表即可查看我们列表页的配置信息了: 其实这个最简单了,首先我们先来完成他控制器的代码: public function lists(){ $mod = M('Conf')->se ...
- Nginx完整配置配置样例【官方版】
我们主要参考nginx官方给出的完整配置的样例: https://www.nginx.com/resources/wiki/start/topics/examples/full/# 完整摘录如下: n ...
- Hystrix参数配置
1.Hystrix参数配置文档 2.Hystrix参数配置示例 import org.springframework.beans.factory.annotation.Autowired; impo ...
- nginx.conf 集群完整配置
###############################nginx.conf 集群完整配置############################### #user nobody; # user ...
- java ant 编译打包build.xml完整配置范例
java ant 编译打包build.xml完整配置范例 <?xml version="1.0" encoding="UTF-8" ?> <p ...
随机推荐
- LNMP与LAMP的工作原理
LAMP的实现原理 LAMP=Linux+Apache+Mysql+PHP.#工作原理:浏览器向服务器发送http请求,服务器 (Apache) 接受请求,由于php作为Apache的组件模块也会一 ...
- 在k8s上安装Jenkins及常见问题
持续集成和部署是DevOps的重要组成部分,Jenkins是一款非常流行的持续集成和部署工具,最近试验了一下Jenkins,发现它是我一段时间以来用过的工具中最复杂的.一个可能的原因是它需要与各种其它 ...
- Django的下载与基本命令
1.下载Django: pip3 install django==2.1.2 2.创建一个django project django-admin startproject 项目名称 3.在项目目录下创 ...
- MIT线性代数:19.行列式和代数余子式
- 8.5 NOIP 模拟测试 13
今天的考试说实话T1很简单没A,我是傻X.T2T3难得一批,但是暴力的分还是拿了! 总结一下就是:骗分过样例,暴力出奇迹!只要瞎搞就行了! 话说现在终于不像之前那么傻了,终于知道打暴力了,因为之前暴力 ...
- 『题解』洛谷P2357 守墓人
Portal Portal1: Luogu Description 在一个荒凉的墓地上有一个令人尊敬的守墓人,他看守的墓地从来没有被盗过, 所以人们很放心的把自己的先人的墓安顿在他那守墓人能看好这片墓 ...
- Python3.x安装教程及环境变量配置
python3.x安装 1.直接到官网https://www.python.org/下载,安装就可以了. 2.安装比较简单,点exe文件一直下一步就可以了(注意:安装的时候有个选择是否添加环境变量,这 ...
- [转载]2.4 UiPath循环活动While的介绍和使用
一.While循环的介绍 先判断条件是否满足, 如果满足, 再执行循环体, 直到判断条件不满足, 则跳出循环 二.While循环在UiPath中的使用 1. 打开设计器,在设计库中新建一个Flowch ...
- 微信小程序云开发获取文件夹下所有文件
上周一个高中同学让我帮他做个图片展示的公众号,因为一直在加班的原因,所以一时忘了,昨晚想起来就赶紧加班加点的帮他弄了下,遇到了个问题,记录一下. 他的需求是要有个后台给他上传图片并且将图片归类,前端公 ...
- 易初大数据 2019年11月10日 spss习题 王庆超
◆1.一个数据文件包含下列数据,5个家庭没有汽车(编码为0),20个家庭有一辆汽车(编码唯1),10个家庭拥有两辆汽车(编码为2)指出下列哪种统计量适用于描述该数据并计算出统计量的值.A A拥有汽车数 ...