Can rocketmq message backlog handle real-time messaging consumption

lheleven 注册会员
2023-02-27 10:10

This answer quotes ChatGPT

1. For RocketMQ's message backlog, consider the following aspects to increase concurrent consumption by consumers:
· Increase consumer instances: Increase concurrent consumption capacity by increasing consumer instances, thereby reducing message backlog time.
· Adjust the number of consuming threads: Concurrent consumption can be improved by adjusting the number of consuming threads in the consumer instance. In general, 1-2 times the number of CPU cores is appropriate.
· Adjust batch size of consumer consumption messages: You can improve the concurrent consumption capability of consumers by adjusting batch size of consumer consumption messages, which can process more messages at once and reduce the number of times consumers consume messages.
2. For scenarios that require prompt response, RocketMQ's synchronous sending mode can be considered. After sending a message to the middleware, wait for the consumer to return the response result before proceeding to the next step. This will increase the waiting time, but can ensure the reliability and real-time of the message. At the same time, it can also improve the concurrent consumption capacity of consumers and reduce the time of message backlog, so as to get the response result of consumers as soon as possible. If the volume of messages sent by the client is very high, consider using message peaking techniques, such as traffic limiting and message batch processing, to reduce the risk of message backlogs.

dboy2233 注册会员
2023-02-27 10:10

RocketMQ can improve message throughput, but if a client sends a large number of calls, You create a backlog of messages. To solve this problem, you can do the following:

  1. Increase the number of consumers: Increasing the number of consumers increases the ability to consume concurrently, thereby reducing the backlog.

  2. Adjust the number of queues: RocketMQ allows you to have more than one queue for a Topic and can adjust the number of queues to reduce backlogs.

  3. Adjust message storage times: RocketMQ allows you to set message storage times, which can be adjusted to reduce backlogs.

  4. Using multi-threaded asynchronous processing: Using multi-threaded asynchronous processing can effectively reduce backlogs while increasing the capacity for concurrent consumption. For example:

    // 创建一个新的线程来处理消息
    Thread thread = new Thread(){
     public void run(){
         // 处理拨打电话的逻辑代码

    The answer is not easy, so take it.

About the Author

Question Info

Publish Time
2023-02-27 10:10
Update Time
2023-02-27 10:10