最近在学习Dubbo源码,当学习到Dubbo中有关EagerThreadPool相关知识时遇到了一个问题,下面是我的dubbo-demo的一些配置:
然后我使用Jmeter进行压测,模拟高并发场景
紧接着,使用 jmeter -n -t命令执行压测
在这个过程中,会出现 Dubbo线程池耗尽的警告信息
[08/09/22 10:13:07:886 CST] NettyServerWorker-3-4 WARN support.AbortPolicyWithReport: [DUBBO] Thread pool is EXHAUSTED! Thread Name: dubbo-demo-annotation-provider-198.18.0.1:20880, Pool Size: 10 (active: 1, core: 5, max: 10, largest: 10), Task: 92341 (completed: 92340), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://198.18.0.1:20880!, dubbo version: , current host: 198.18.0.1 [08/09/22 10:13:07:886 CST] NettyServerWorker-3-5 WARN support.AbortPolicyWithReport: [DUBBO] Thread pool is EXHAUSTED! Thread Name: dubbo-demo-annotation-provider-198.18.0.1:20880, Pool Size: 10 (active: 0, core: 5, max: 10, largest: 10), Task: 92342 (completed: 92341), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://198.18.0.1:20880!, dubbo version: , current host: 198.18.0.1 [08/09/22 10:13:07:886 CST] NettyServerWorker-3-8 WARN support.AbortPolicyWithReport: [DUBBO] Thread pool is EXHAUSTED! Thread Name: dubbo-demo-annotation-provider-198.18.0.1:20880, Pool Size: 10 (active: 0, core: 5, max: 10, largest: 10), Task: 92342 (completed: 92341), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://198.18.0.1:20880!, dubbo version: , current host: 198.18.0.1 [08/09/22 10:13:07:886 CST] NettyServerWorker-3-9 WARN support.AbortPolicyWithReport: [DUBBO] Thread pool is EXHAUSTED! Thread Name: dubbo-demo-annotation-provider-198.18.0.1:20880, Pool Size: 10 (active: 0, core: 5, max: 10, largest: 10), Task: 92342 (completed: 92341), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://198.18.0.1:20880!, dubbo version: , current host: 198.18.0.1 [08/09/22 10:13:07:886 CST] NettyServerWorker-3-6 WARN support.AbortPolicyWithReport: [DUBBO] Thread pool is EXHAUSTED! Thread Name: dubbo-demo-annotation-provider-198.18.0.1:20880, Pool Size: 10 (active: 0, core: 5, max: 10, largest: 10), Task: 92341 (completed: 92340), Executor status:(isShutdown:false, isTerminated:false, isTerminating:false), in dubbo://198.18.0.1:20880!, dubbo version: , current host: 198.18.0.1
本来也很正常,Jmeter文件里设置了线程数为 100
但是报错信息的 Pool的activeCount竟然不是10,如果线程池耗尽的话,这里的activeCount应该是10才对。
这是为什么?
然后我改造了一下,增加了一下日志打印参数,如下:
之后还是使用Jmeter进行压测,结果如下:
submittedTaskCount、active和Pool Size还是对不上
原提问者GitHub用户workingonescape
debug 看了下,active 小于 pool 的原因是中间的 queue 存在竞争以及 worker 获取任务不够及时导致的。queue 队列长度只有 1,在高并发场景下会导致 worker 来不及获取任务就有新任务提交导致被拒绝。
原回答者GitHub用户AlbumenJ
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。