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

Steve Powell steve at rabbitmq.com
Tue May 8 12:35:28 BST 2012


Of course, as Matthias pointed out, everything eventually goes down a
connection. If this is shared between the channels then SENDing
messages from the client will clearly serialise at the connection level.
This is what I'm seeing here, too.

Individual messages are not split into chunks (as they would have to be
to multi-plex them with others on the network connection), so each
message will block out all other activity on the connection until it
is completed.  Larger messages will block for longer.

The reason why you might want multiple channels on one connection is if
you want to multi-thread work at the client end -- for example Consumer
callback work. Each connection has a thread-pool of executors to run
consumer callbacks (deliveries and so on) so that multiple channels can
run their callbacks simultaneously. Frames received from the server
still come in serially over the connection, but the callbacks they
trigger can run in independent threads if they are for distinct
channels.  You appear not to be doing any consuming, so this is not
your problem.

AFAIK there isn't a standard for multi-plexing channels/connections at
the client end, but I suggest that you simply increase the number of
underlying connections to relieve the bottleneck you are seeing. If, for
instance, you introduce, 5 connections with 10 channels each you could
see if this helps things.

Varying the number of channels per connection will allow you to tune the
potential contention for each connection. Only you can tell what 
the likely contention is to be.  The selector process for channels might
want to favour channels which are for connections with fewer used
channels already.

Let us know how you fare.

Steve Powell  (a happy bunny)
----------some more definitions from the SPD----------
chinchilla (n.) Cooling device for the lower jaw.
socialcast (n.) Someone to whom everyone is speaking but nobody likes.
literacy (n.) A textually transmitted disease usually contracted in childhood.

On 4 May 2012, at 15:43, Gautam Bakshi wrote:

> Thanks Matthias and Steve. 
> Is there a better(or more common/supported) way to pool channels(so I reduce blocking on threaded message passing)?  I'd rather not waste anyone's time if there's already a tried and test solution out there for pooling.
> Enjoy the holidays!
> On Fri, May 4, 2012 at 7:24 AM, Matthias Radestock <matthias at rabbitmq.com> wrote:
> 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.
> -- 
> Regards,
> Gautam Bakshi
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120508/2ec2eb74/attachment.htm>

More information about the rabbitmq-discuss mailing list