我正在使用Hystrix库来处理网络呼叫。 这是我用于线程池配置的
HystrixThreadPoolProperties.Setter threadPropSetter = HystrixThreadPoolProperties.Setter(); threadPropSetter.withCoreSize(100); threadPropSetter.withMaxQueueSize(1000);我正在使用常见的HytrixCommandKey和HytrixThreadPoolKey创建1000个HytrixCommand对象的负载。 但是线程池在服务前100个线程之后执行回退逻辑,而不是使用线程池队列。 这可以通过将threadpool,coreSize设置为1000来解决。但我使用java,并将coreSize设置为1000将产生1000个线程,这将消耗大量的系统资源。
任何人都可以为此提供解决方案,以便线程池队列实际上可以对线程进行排队,而不仅仅是恢复到回退逻辑?
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 ?
最满意答案
刚刚在我的main方法中添加了一个Thread.sleep(),以便在创建和排队命令后JVM不会终止。 现在工作正常。
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.
更多推荐
发布评论