[rabbitmq-discuss] Slow throughput on consume side using java client API

scott w scottblanc at gmail.com
Thu Nov 26 01:19:25 GMT 2009


I'm not seeing the expected throughput on the consume side of things using
the Java client API and looking for some suggestions. The way I've set up my
tests I create N=25 channels/queue consumers for a single queue (according
to the java api docs you can't have more than one thread on a given channel
at once) and then I have 50 threads that fill up the queue (publish
throughput is fine) and then another 50 threads which pull from the queue. I
synchronize on the channels and each thread uses round robin to to select a
channel and queue consumer pair and uses that to do the consume and ack. But
even after some twiddling I am not able to get beyond 50 reads per sec which
is less than 10x what I am seeing on the publish side. Below is what the key
code looks like. Any suggestions for what may be causing the slowness?

thanks,
Scott

Here is the consume code looks like:

    Integer channelNum = pickRandomChannel();
    Channel channel = getChannel( channelNum );
    QueueingConsumer consumer = getConsumer( channelNum );
    synchronized (getChannel( channelNum )) {
      try {
        channel.basicConsume( getQueueName(), noAck, consumer ); //noAck =
false here
      } catch (IOException e) {
        logger.warn( "Exception when consuming message from queue: " +
getQueueName(), e );
      }
      try {
        QueueingConsumer.Delivery delivery = consumer.nextDelivery(
this.defaultTimeout );
        if (delivery == null) {
          return null;
        }
        return delivery.getBody()
      } catch (InterruptedException ie) {
        logger.warn( "Interruped exception on next delivery", ie );
        return null;
      }
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20091125/c041d734/attachment.htm 


More information about the rabbitmq-discuss mailing list