Search code examples
socketstcprabbitmqamqp

RabbitMQ Channels and Connections


I've trying to understand the concept of channels and connections in RabbitMQ, I understand it in a high-level, a connection is a real connection implemented as TCP socket to the broker, channels are virtual connections that use the sane real connection to communicate. So channels are multiplexed through the same connection.

However in a low-level how is this implemented, TCP sockets are non-blocking? I've read that using multiple connections don't increase performance why not ? When a channel uses the connection i imagine the calls are serialized right? So wouldn't multiple connections allow me to send and receive data faster.

I know I'm missing something here so that's why I'm asking for some clarification.

Thanks.


Solution

  • Whether a server or client uses non-blocking sockets is an implementation detail. An implementation that needs high performance probably uses non-blocking socket; but e.g. the RabbitMQ server uses the usual lightweight Erlang process model to achieve concurrency.

    You are free to use multiple AMQP connections - though in most cases you should be good with one connection and multiple channels. TCP has a relatively high overhead, and multiplexing channels on top of a TCP connection reduces this overhead.