[rabbitmq-discuss] Starts slow, but then fast.

Tim Fox tim at rabbitmq.com
Tue Jun 14 15:42:55 BST 2011


If you're starting a JVM every time you run the producer code, then the 
delay is probably because the VM hasn't had time to "warm up" and the 
JIT to kick in.

JIT can take 10s of seconds to minutes to really kick in and get the 
best benefit. (This is one reason why JVM is not really suited to 
scripting applications).

This is why when running any benchmarks it's always sensible to your let 
your client application warm up by sending and consuming messages for a 
minute or more before you start taking measurements.

On 14/06/11 15:33, Robert wrote:
> Hi,
>
> I did the "Hello, World" - Example from 
> http://www.rabbitmq.com/tutorials/tutorial-one-java.html
>
> and only added to send the message 100000 times.
>
> Any ideas on the following behaviour:
>
> The first couple of hundred messages being received pretty slowly (per 
> 100 messages 2-3 seconds), then it improves up to a couple thausand 
> messages a little bit (per 1000 messages 2-3 seconds), but then - peng 
> - from around 8000 messages it is extremly fast (rest in about 1 
> second !!!).
>
> And it doesn't matter if I ran the producer code 1 time or a couple 
> times. It is always the same bahaviour. (Also, the producers loop is 
> done much before all messages being consumed - so, it looks as the 
> sending is fast).
>
> What is going on. Any ideas ?
>
> Cheers, Rob.
>
> Here my code (but in Scala):
>
>
>
> object ConsumerTest {
>   val QUEUE_NAME = "robs_queue"
>
>   def main(args: Array[String]) {
>     val factory = new ConnectionFactory();
>     factory.setHost("localhost");
>     val connection = factory.newConnection();
>     val channel = connection.createChannel();
>     channel.queueDeclare(AMQPTesterRaw.QUEUE_NAME, false, false, 
> false, null)
>
>     val consumer = new QueueingConsumer(channel)
>     channel.basicConsume(AMQPTesterRaw.QUEUE_NAME, true, consumer)
>
>     while(true){
>       val del = consumer.nextDelivery();
>       println("arrived = " + new String(del.getBody))
>     }
>
>   }
> }
>
> object ProducerTest {
>   def main(args: Array[String]) {
>     val factory = new ConnectionFactory();
>     factory.setHost("localhost");
>     val connection = factory.newConnection();
>     val channel = connection.createChannel();
>     channel.queueDeclare(AMQPTesterRaw.QUEUE_NAME, false, false, 
> false, null)
>
>     for(x <- 1 to 100000){
>       val msg = "Hello World(" + x + ")"
>       channel.basicPublish("", AMQPTesterRaw.QUEUE_NAME, null, 
> msg.getBytes)
>     }
>
>     channel.close()
>     connection.close()
>
>   }
> }
>
>



More information about the rabbitmq-discuss mailing list