RabbitMQ错误超时 [英] RabbitMQ error timeout

查看:352
本文介绍了RabbitMQ错误超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置RabbitMQ来解析来自外部API的大约20.000个请求,但是几分钟后它一直保持超时.确实可以正确解析20.000个请求中的2000个.

I've set up RabbitMQ in order to parse some 20.000 requests from an external API but it keeps timing out after a few minutes. It does get to correctly parse about 2000 out of the total 20.000 requests.

日志文件显示:

=INFO REPORT==== 16-Feb-2016::17:02:50 ===
accepting AMQP connection <0.1648.0> (127.0.0.1:33091 -> 127.0.0.1:5672)

=ERROR REPORT==== 16-Feb-2016::17:03:21 ===
closing AMQP connection <0.1648.0> (127.0.0.1:33091 -> 127.0.0.1:5672):
{writer,send_failed,{error,timeout}}

我已经增加了心跳值,但是我不知道为什么会超时.配置为:Ubuntu 14.04,NGINX 1.8.1,RabbitMQ 3.6.0

I've already increased the heartbeat value but I cannot figure out why it's timing out. Configuration is: Ubuntu 14.04, NGINX 1.8.1, RabbitMQ 3.6.0

感谢您的宝贵时间和投入!

I'd appreciate your time and input !

推荐答案

我刚刚在python中解决了类似的问题.就我而言,它是通过减少使用者的预取次数来解决的,从而减少了在接收缓冲区中排队的消息.

I've just solved a similar problem in python. In my case, it was solved by reducing the prefetch count on the consumer, so that it had fewer messages queued up in its receive buffer.

我的理论是,使用者上的接收缓冲区已满,然后RMQ尝试将其他消息写入使用者的套接字,但由于使用者的套接字已满而无法发送. RMQ在此套接字上阻塞,最终超时并仅关闭使用者上的连接. 具有较小的预取队列意味着套接字接收缓冲区不会被填满,并且RMQ能够写入它尝试执行的任何簿记消息,因此写入时不会超时,也不会关闭连接.

My theory is that the receive buffer on the consumer gets full, and then RMQ tries to write some other message to the consumer's socket and can't due to the consumer's socket being full. RMQ blocks on this socket, and eventually timeouts and just closes the connection on the consumer. Having a smaller prefetch queue means the socket receive buffer doesn't get filled, and RMQ is able to write whatever bookkeeping messages it was trying to do and so doesn't timeout on its writes nor close the connection.

虽然这只是一个理论,但似乎在我的测试中成立.

This is just a theory though, but it seems to hold in my testing.

在Python中,可以这样设置预取次数:

In Python, setting the prefetch count can be done like so:

subChannel.basicQos(10);

(感谢@ shawn-guo提醒我添加此代码段)

(Thanks to @shawn-guo for reminding me to add this code snippet)

这篇关于RabbitMQ错误超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆