首页 > 解决方案 > Hystrix 线程池 maximumSize、coreSize 和 allowMaximumSizeToDivergeFromCoreSize 不起作用?

问题描述

我已将 hystrix 线程池配置设置为 - coreSize=10maximumSize=100allowMaximumSizeToDivergeFromCoreSize=true设置为 command 键。我部署了应用程序,但是当 QPS 很高时它拒绝线程 -

Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@7bb2e868 rejected from java.util.concurrent.ThreadPoolExecutor@39627710[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = 3409]
    at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
    at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
    at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$ThreadPoolWorker.schedule(HystrixContextScheduler.java:172)
    at com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$HystrixContextSchedulerWorker.schedule(HystrixContextScheduler.java:106)

我正在使用hystrix-javanica 1.5.12版本。这不起作用,因为排队的任务为 0。

其余的默认值如下(下面的名称被抽象了一点) -

    isCircuitBreakerEnabled = true;
    circuitBreakerRequestVolumeThreshold = 10;
    isFallBackEnabled = false;
    circuitBreakerSleepWindow = 10000;
    circuitBreakerErrorThresholdPercentage = 50;
    circuitBreakerForceOpen = false;
    circuitBreakerForceClosed = false;
    metricsRollingStats = 10000;
    executionIsolationThreadTimeOut = 20000;
    executionIsolationStrategy = "THREAD";
    executionTimeOutEnable = true;
    poolCoreSize = 10;
    poolMaxSize = 15;
    poolMaxQueueSize = -1;
    keepAliveTime = 1;
    poolQueueSizeRejectionThreshold = 1;
    allowMaximumSizeToDivergeFromCoreSize = false;

我正在关注这个问题 - https://github.com/Netflix/Hystrix/issues/1436。2017 年又有人报告了此版本的类似问题。

您认为我缺少任何配置吗?我应该更改 executionIsolationStrategy 以Semaphore使其工作吗?

标签: javamultithreadingthreadpoolhystrixnetflix-archaius

解决方案


推荐阅读