[rabbitmq-discuss] Pika connection negotiation behavior

Matthias Radestock matthias at rabbitmq.com
Thu Jun 6 08:05:48 BST 2013


Maitreya,

On 06/06/13 06:35, maitreya wrote:
> I wanted to set the heartbeat interval to 3600s(assuming pika is
> single threaded and can analyze the heartbeat events only between
> requests).
> [...]
> I think the heartbeat interval should be flexible enough for different
> type of workers.

This is the crux of the problem.

The heartbeat interval needs to be tuned to the network conditions. The 
ideal setting is actually "as short as possible, without impacting 
performance", since that way we a) minimise the delay in detecting dead 
connections, and b) minimise the chances of the connection getting 
killed prematurely due to idleness.

Having to lengthen the interval artificially - e.g. so that 
single-threaded clients can process a whole message - conflicts with 
that. More generally, client libraries / applications should be 
responsive to incoming AMQP traffic. I don't know enough about pika and 
python threading to ascertain whether there is a convenient way to 
achieve that.

Having said that, as was noted in this thread earlier, there is nothing 
stopping clients from setting the interval to whatever they like. 
However, I'd caution against a default client library behaviour of 
"accept whatever the app says, regardless of the server setting" since 
that takes away any possibility for server-side adjustments.

And on that note...

you can adjust the server-suggested heartbeat interval from the default 
600s by setting the 'heartbeat' configuration variable in the server's 
rabbitmq.config, as documented at 
https://www.rabbitmq.com/configure.html#config-items


Regards,

Matthias.


More information about the rabbitmq-discuss mailing list