Hystrix Threadpool队列无法正常工作(Hystrix Threadpool Queue not working properly)

编程入门 行业动态 更新时间:2024-10-24 22:30:56
Hystrix Threadpool队列无法正常工作(Hystrix Threadpool Queue not working properly)

我正在使用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.

更多推荐

本文发布于:2023-08-06 23:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457569.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:队列   无法正常   工作   Threadpool   Hystrix

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!