lwclover commented on a change in pull request #3981:
URL: https://github.com/apache/rocketmq/pull/3981#discussion_r833958324



##########
File path: 
client/src/main/java/org/apache/rocketmq/client/impl/producer/DefaultMQProducerImpl.java
##########
@@ -135,7 +135,8 @@ public DefaultMQProducerImpl(final DefaultMQProducer 
defaultMQProducer, RPCHook
                 public Thread newThread(Runnable r) {
                     return new Thread(r, "AsyncSenderExecutor_" + 
this.threadIndex.incrementAndGet());
                 }
-            });
+            },
+            new ThreadPoolExecutor.CallerRunsPolicy());

Review comment:
       
rocketmq默认的异步线程池是大小和cpu核数相等,阻塞队列默认是5w,我们生产应用使用k8s部署一般cpu也就2个核左右,当时是准备异步发送8w+的消息。
   
出现了RejectedExecutionException异常,这个倒是容易理解,发送到线程池的速度肯定是快于producer发送到broker的速度的,当时我建议业务set一个自定义线程池并配置淘汰策略为CallerRunsPolicy,解决了这个问题。
   
   如果发生了Full gc和发送慢的问题,我觉得应该继续优化jvm和broker解决。




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to