[rabbitmq-discuss] RabbitMQ Latency

Tom Wrigg tadw99 at googlemail.com
Thu Aug 16 01:07:20 BST 2012


I'm running RabbitMQ with the node.js amqp-node client. I've set up a 
simple publish/consume test in two different ways each produces a different 
latency and I can't work out why. The latency was measured from the time 
the message was sent to the time it was delivered.

The first method uses two separate processes - one for the publishing app - 
one for the consuming app. It produces a latency of about at 4ms. The 
second method uses just one app to produce and consume. This produces a 
latency of about 40ms. Can anyone explain to me why? Thank you for your 
time.

*Method #1 Producer:*

    var amqp = require('amqp'),
> connection = amqp.createConnection({host:'localhost'}),
> testExchange = {};
> connection.on('ready', function(){
> testExchange = connection.exchange('testExchange', {type:'topic', 
> autoDelete:true});
> testMessage();
> });

 

>
> function testMessage(){
> console.log('message sent');
> testExchange.publish('test.message', { msg:'testMessage', time: new 
> Date().getTime() });
> setTimeout(testMessage, 500);
> }

 

>  

> * Method #1 Consumer*
*
*

var amqp = require('amqp'),
> connection = amqp.createConnection({host:'localhost'}),
> connection.on('ready', function(){
> var testExchange = connection.exchange('testExchange', {type:'topic', 
> autoDelete:true});
> var testQ = connection.queue('testQ', function(queue){
> queue.bind('testExchange', 'test.#');
> queue.subscribe( function(message){
> console.log('message received');
> var now = new Date().getTime();
> console.log(now-message.time);
> });
> });
> });


*Method #2 Producer and Consumer *

var amqp = require('amqp'),
> connection = amqp.createConnection({host:'localhost'}),
> testExchange = {};
> connection.on('ready', function(){
> testExchange = connection.exchange('testExchange', {type:'topic', 
> autoDelete:true});
> var testQ = connection.queue('testQ', function(queue){
> queue.bind('testExchange', 'test.#');
> queue.subscribe( function(message){
> console.log('message received');
> var now = new Date().getTime();
> console.log(now-message.time);
> });
> testMessage();
> });
> });
> function testMessage(){
> console.log('message sent');
> testExchange.publish('test.message', { msg:'testMessage', time: new 
> Date().getTime() });
> setTimeout(testMessage, 500);
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120815/d5736f4c/attachment.htm>


More information about the rabbitmq-discuss mailing list