【问题标题】:How to find the number of active threads in a hystrix thread pool?如何在 hystrix 线程池中找到活动线程的数量?
【发布时间】:2019-12-18 01:28:56
【问题描述】:

我正在尝试微调 hystrix 线程池核心大小和最大大小。为此,我需要随时了解并绘制池中的活动线程数。有办法吗?

这是正确的方法吗?

HystrixThreadPoolKey hystrixThreadPoolKey = new HystrixThreadPoolKey() {
            @Override
            public String name() {
                return threadPoolKey;
            }
        };
HystrixThreadPoolMetrics hystrixThreadPoolMetrics = HystrixThreadPoolMetrics.getInstance(hystrixThreadPoolKey);
log.info("Hystrix active threads: {}", hystrixThreadPoolMetrics.getCurrentActiveCount().toString());

我不确定,因为当我使用它时,当 corePoolSize 设置为 10 时,活动线程数为 0。

【问题讨论】:

    标签: threadpool java-threads hystrix


    【解决方案1】:

    此代码工作正常(在对时间进行空检查之后,直到没有发出请求)。但正确的方法应该是使用 Netflix 的伺服器。

    Netflix Announcement

    How to Use

    引用公告中的部分内容:

    Servo 旨在使开发人员能够轻松地从其应用程序代码中导出指标、向 JMX 注册并将它们发布到外部监控系统

    (同时活动线程池大小可以小于核心大小)

    【讨论】:

      猜你喜欢
      • 2011-07-11
      • 2016-09-08
      • 2016-10-11
      • 1970-01-01
      • 2019-01-29
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多