[rabbitmq-discuss] please help understanding why my pool of channels are blocking.

Matthias Radestock matthias at rabbitmq.com
Fri May 4 12:24:40 BST 2012


On 03/05/12 04:34, Gautam Bakshi wrote:
> I have a multi-threaded application that I was considering using
> rabbitmq to manage the queue but I'm getting alot of blocking between
> my channels.  Is there a preferred way to setup pools?
>
> I'm a bit new to Java so I used to the pools from apache commons but
>  when I profile the channels are all blocking each other.  To test if
>  dedicated connections per thread worked better I made an example of
> it as well and it does not block when the same program has a single
> channel per connection.
>
> So my question, do channels block each other or am I doing something
>  wrong(using java api wrong or misunderstanding
> connection/channels)?

Channels are multiplexed on the underlying connection. So when an app
is, say, publishing messages on multiple channels, these activities will
be serialised at the point the client interacts with the network socket.

> there a more preferred way? Unrelated to the question, but I was also
>  wondering is there any difference between channels and connections
> in terms of throughput(i.e. would there be any benefit of using
> dedicated connections ignoring the overhead in
> establishing/maintaining the connection)?

You can get exploit more parallelism in both the client and server when
using multiple connections compared to multiple channels. But it is
ultimately more costly in CPU and memory. Plus of course network
capacity is bounded, so if you are saturating that with a single
connection then using more than one will not gain anything.

So the answer on whether multiple channels or multiple connections are
better very much depends on the application, the hardware environment
at the client and broker end, and the network. Hence your best bet is to 
conduct some tests, which you are already doing :)

Regards,

Matthias.


More information about the rabbitmq-discuss mailing list