简体   繁体   中英

Hystrix Threadpool Queue not working properly

I am using Hystrix library to process network calls. This is what I am using for thread pool configuration

HystrixThreadPoolProperties.Setter threadPropSetter = HystrixThreadPoolProperties.Setter();
threadPropSetter.withCoreSize(100);
threadPropSetter.withMaxQueueSize(1000);

I am creating a load of 1000 HytrixCommand objects using a common HytrixCommandKey and HytrixThreadPoolKey. But the thread pool executes the fallback logic after the first 100 threads are serviced, instead of using the threadpool queue. This can be solved by setting the threadpool,coreSize to 1000. But I am using java, and setting the coreSize to 1000 will spawn 1000 threads, which will consume a lot of system resource.

Can anyone provide a solution for this, so that the threadpool queue can actually queue the threads instead of just reverting to the fallback logic ?

Just added a Thread.sleep() in my main method so that the JVM doesnt terminate after the commands have been created and queued. Works fine now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM