java - 如何为 executionIsolationSemaphoreMaxConcurrentRequests 选择正确的值
问题描述
我想知道如何在 spring-cloud-gateway 的 hystrix 配置中正确设置 executionIsolationSemaphoreMaxConcurrentRequests 的值。默认值为 10,但在我们的例子中,一个用户可以超过它。我应该如何选择正确的值?如何根据 hystrix 中的时间窗口和预期的用户数来计算它?
下面的示例配置:
@Value("${hystrix.circuitBreakerRequestVolumeThreshold : 20}")
private int circuitBreakerRequestVolumeThreshold;
@Value("${hystrix.executionTimeoutInMilliseconds : 30000}")
private int executionTimeoutInMilliseconds;
@Value("${hystrix.circuitBreakerSleepWindowInMilliseconds : 10000}")
private int circuitBreakerSleepWindowInMilliseconds;
@Value("${hystrix.metricsRollingPercentileWindowInMilliseconds : 60000}")
private int metricsRollingPercentileWindowInMilliseconds;
@Value("${hystrix.metricsHealthSnapshotIntervalInMilliseconds : 500}")
private int metricsHealthSnapshotIntervalInMilliseconds;
@Value("${hystrix.circuitBreakerErrorThresholdPercentage : 50}")
private int circuitBreakerErrorThresholdPercentage;
@Value("${hystrix.metricsRollingStatisticalWindowInMilliseconds : 10000}")
private int metricsRollingStatisticalWindowInMilliseconds;
@Value("${hystrix.executionIsolationSemaphoreMaxConcurrentRequests : 50}")
private int executionIsolationSemaphoreMaxConcurrentRequests;
public Consumer<HystrixGatewayFilterFactory.Config> getHystrixConfig(String groupName, String serviceName) {
return getHystrixConfig(groupName, serviceName, executionTimeoutInMilliseconds);
}
public Consumer<HystrixGatewayFilterFactory.Config> getHystrixConfig(String groupName, String serviceName, int timeout) {
return config -> config
.setSetter(HystrixObservableCommand.Setter
.withGroupKey(HystrixCommandGroupKey.Factory.asKey(groupName))
.andCommandKey(HystrixCommandKey.Factory.asKey(serviceName))
.andCommandPropertiesDefaults(HystrixCommandProperties.Setter()
.withCircuitBreakerEnabled(true)
.withCircuitBreakerRequestVolumeThreshold(circuitBreakerRequestVolumeThreshold)
.withExecutionIsolationSemaphoreMaxConcurrentRequests(executionIsolationSemaphoreMaxConcurrentRequests)
.withExecutionTimeoutInMilliseconds(timeout)
.withCircuitBreakerSleepWindowInMilliseconds(circuitBreakerSleepWindowInMilliseconds)
.withMetricsRollingPercentileWindowInMilliseconds(metricsRollingPercentileWindowInMilliseconds)
.withMetricsHealthSnapshotIntervalInMilliseconds(metricsHealthSnapshotIntervalInMilliseconds)
.withCircuitBreakerErrorThresholdPercentage(circuitBreakerErrorThresholdPercentage)
.withMetricsRollingStatisticalWindowInMilliseconds(metricsRollingStatisticalWindowInMilliseconds)
)
)
.setFallbackUri("forward:/hystrixfallback");
}
解决方案
推荐阅读
- html - 滑块图像被另一个 div 标签重叠
- python-3.x - python tensorflow中一种热编码的分类级别
- php - 使用 php 在 android 和 ios 上使用 Infusionsoft 发送推送通知
- jquery - 使用 jQuery 设置 Html.TextBoxFor 值不会反映在模型 POST 中
- node.js - 限制 API + 特定范围的 IP
- spacy - 是否可以从非自然句子中获取日期标签?
- ios - 如何在 CollectionView iOS Swift 4 中显示不显示单元格的标题?
- javascript - 使用 JavaScript 在 word 文件中使用 HighChart Js 导出 Html 元素
- android - 如何在android中动态更改TextToSpeech的重音
- python - Pandas Groupby:同一列上的聚合,但基于多个标准的多个总计