MQ队列堆积太长,消费不过来怎么办[通俗易懂]

MQ队列堆积太长,消费不过来怎么办[通俗易懂]转自:http://windwrite.com/archives/603 我们现有的业务就面临此问题,消息生产太快,消费不过来,导致队列堆积很长,把服务器内存耗尽,这时RabbitMQ的处理能力很低…

转自:http://windwrite.com/archives/603

我们现有的业务就面临此问题,消息生产太快,消费不过来,导致队列堆积很长,把服务器内存耗尽,这时RabbitMQ的处理能力很低下。

我在RabbitMQ社区发邮件问了下:

 

We have the queue publisher and subscriber, the subscriber is going with multi-threads.

The problem is the queue has been increasing too quickly, the consumers can not follow the increment speed, as you see:

root@ubuntu:~# for i in `seq 1 10`;do rabbitmqctl list_queues -p /actionlog;sleep 1;done
Listing queues …
queue_storm_actionlog 12665787
…done.
Listing queues …
queue_storm_actionlog 12670873
…done.
Listing queues …
queue_storm_actionlog 12667975
…done.
Listing queues …
queue_storm_actionlog 12672645
…done.
After one day or about, the queue size can be more than 20 millions, thus RabbitMQ becomes high load and the consuming process is very slow.

收到的答复邮件内容如下:

Increase # of throughput of consumers or reduce publishing rate. If consumers cannot
catch up, hardware upgrades will only offset the moment when systems starts running
low on resources.

If messages can be lost, 3.1 introduces a new feature, queue length limit:
http://www.rabbitmq.com/maxlength.html

Further to the suggestion of imposing a maximum queue length, you could
also consider imposing a maximum message age and instruct the broker to
discard messages that become stale: http://www.rabbitmq.com/ttl.html

总结起来解决方案大体包括:

    • 增加消费者的处理能力,或减少发布频率
    • 单纯升级硬件不是办法,只能起到一时的作用
    • 考虑使用队列最大长度限制,RabbitMQ 3.1支持
    • 给消息设置年龄,超时就丢弃

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
转载请注明出处: https://daima100.com/11189.html

(0)
上一篇 2022-12-15
下一篇 2022-12-15

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注