[rabbitmq-discuss] Scaling

Emile Joubert emile at rabbitmq.com
Fri Oct 29 15:17:18 BST 2010


Hi Reefee,

On 29/10/10 10:51, Reefee wrote:
> 
> I have a Java Servlet that listens to external messages delivered via HTTP
> POST.
> I am using the rabbitmq. Java SDK 
> The servlet then processess them and stores them on to a RabbitMQ queue.
> 
> In order to offer best performance and scalability what is the reccomended
> usage of Connections and channels ?
> i.e. Have a single connection that gets re-used accross all requests and
> with each message being posted to the queue by its own channel instance (as
> it seems Channels being used by multiple threads is not a good idea).

It is possible to share a channel, but you will need to serialise access
to it. It is simpler and recommended to establish a channel per thread
as you suggest.

> Or should I create a seperate Connection for each request ?

>From your description it sounds like this client only acts as an AMQP
producer. The normal pattern here would be use one or many long-lived
connections. Also look at the rabbitmq-java-messagepatterns for a
wrapper that maintains long-lived connections. If the client needs to
act as an AMQP consumer as well then establish separate connections for
this purpose.

Creating a new connection per request would make sense if on average
messages are less frequent than network failures and you can tolerate
the additional connection setup overhead.


Regards

Emile





More information about the rabbitmq-discuss mailing list