[rabbitmq-discuss] acquiring channels per connection

Marek Majkowski majek04 at gmail.com
Wed Mar 16 15:42:01 GMT 2011

On Tue, Mar 15, 2011 at 07:11, vorad <vorad.1100 at gmail.com> wrote:
> I am trying to figure out what's the best way to work with rabbitmq - I am
> working on implementing a couple of basic HTTP requests that do some queue
> management (with the Pika library and Tornado as web server). One of the
> first issues I had was how do I actually get the errors out of Pika when
> these happen (say when you're trying to delete a queue that doesn't exist)
> and it seems I figured that out, hopefully (channel.add_on_close_callback)
> Now, the way I tought this was that I have one rabbitmq connection per
> application/web server and one channel as well, which seems pretty bad now
> that I look back, since I can't really do particular error logic per request
> with only one channel per application. So I am trying to switch away from
> this to having one channel per http request. How expensive would be to do
> this (one channel per request) from the rabbitmq perspective and also from
> the Pika's perspective ?

Well, not that expensive if your RabbitMQ is close to the web server.
Opening channel is a synchronous action - a full roundtrip is required.

To avoid that roundtrip you may hava a pool and reuse open channels.

> And also, does this look like a good approach,
> given the fact that I'll have lots of http connections? I know that RabbitMQ
> was made to scale to a big number of channels.

Rabbit can handle many channels.

More information about the rabbitmq-discuss mailing list