Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ latency issues across geographical distance

Tags:

rabbitmq

We have a situation where we have a single RabbitMQ node in US-East, with producers in other zones (Ireland, Sydney etc). We are seeing huge performance hits when queueing from other zones. Sydney -> US-East queue is 1s to queue a message, whereas queuing Sydney -> Sydney is 50ms. It seems a lot of the time is spent creating the channel and declaring the queue.

What options do we have to improve the performance? Could we look at some sort of distributed RabbitMQ cluster, with a node in each region? Would that help us?

Here's the code we are using to test:

var queueConnection = amqp.connect("OUR amqp servers in each region")
var queueName = "test-queue"

var queueMessage = function(message) {
  return queueConnection.then(function(conn) {
    return conn.createChannel()
  }).then(function(ch) {
    var queue = ch.assertQueue(queueName, { durable: false });
    return queue.then(function() {
      ch.sendToQueue(queueName, new Buffer(JSON.stringify(message)), { deliveryMode: true });
      return ch.close()
    });
  })
};

Promise.map(_.range(0, 10), function(item) {
  var timedQueueMessage = timely.promise(queueMessage)
  return timedQueueMessage({ name: "Dom" }).then(function(res) {
    console.log("Completed in " + timedQueueMessage.time + "ms")
  })  
}, { concurrency: 10 }).done(process.exit)
like image 266
Dominic Bou-Samra Avatar asked Nov 09 '22 20:11

Dominic Bou-Samra


1 Answers

For these use cases you should look at Federation or Shovel.

This page explains the pros and cons of each of the distributed options offered by RabbitMQ: http://www.rabbitmq.com/distributed.html

like image 61
old_sound Avatar answered Jan 04 '23 03:01

old_sound