1

To publish messages to RabbitMQ (acknowledged, persistent) from a NodeJS publisher (I'm using bramqp, but the question is generic), what should be channel pooling strategy?

If I create a huge pool (20,000 +) and look out for a free channel every time I need to publish, and then free the channel whenever I get an acknowledgement (keeping in free pool), then at high loads, acknowledgements are delayed, so a high number of channels get created, causing a rapid increase in erlang processes in RabbitMQ, degrading its performance.

If I manage with a very small pool, or no pool, then as soon as the rate is high, socket error is thrown, at which the only option is to reset the complete connection.

What's the best practice here?

Confused
  • 617
  • 1
  • 9
  • 17
  • I'm not sure how the RabbitMQ server behaves regarding a channel - if it creates a new Erlang process for each channel, that concerns me. Can you share additional details as to your operational scenario? – theMayer Aug 19 '15 at 10:55

1 Answers1

-2

I cannot say I understand what you are doing, but it is important to understand that channels are a protocol-level construct. There is no such thing as "channel pooling" - when you begin an interaction with an AMQP server, it uses an existing connection (if available) and creates a new "channel" by assigning an integer value to the channel header during the handshake process. Perhaps your program is actually creating lots of connections?

What I would suggest is to do the following each time you need to publish:

  1. Open a channel
  2. Publish message
  3. Wait for confirms
  4. Close channel
theMayer
  • 15,456
  • 7
  • 58
  • 90
  • @Vlad- The link you put up is relatively new documentation. I’m not sure what the point of it is, but speaking from an architecture standpoint, the protocol specification clearly indicates channels are to be used, then discarded. If RMQ did not implement the spec that way, then this is a serious defect in the implementation. – theMayer Dec 10 '19 at 12:37
  • The link is new documentation but the idea behind high channel churn applies. It is not recommended to open and close a channel for every published message. In most scenarios you should have a channel per thread, or this is what I understand from the docs. – Vlad Dec 11 '19 at 08:28