Deven
Deven

Reputation: 617

How to find the number of active threads in a hystrix thread pool?

I am trying to finetune hystrix threadpool core size and max size. For that I need to know and plot the number of active threads at anytime in the pool. Is there a way to do so?

Is this the right way?

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

I am not sure because when I use this I get active thread count as 0, when the corePoolSize setting is 10.

Upvotes: 0

Views: 1212

Answers (1)

Deven
Deven

Reputation: 617

This code works fine (after putting a null check for the time till no request is made). But the right way should be to use Netflix's servo.

Netflix Announcement

How to Use

Quoting some part from the announcement:

Servo is designed to make it easy for developers to export metrics from their application code, register them with JMX, and publish them to external monitoring systems

(Also active thread pool size can be less than the core size)

Upvotes: 0

Related Questions