Tuning OpenAMQ for low latency


Tuning OpenAMQ means ensuring the broker runs without too many interruptions from the operating latency.


Operating system

First of all you should take your OS into consideration. The OS can schedule other tasks to run instead of OpenAMQ, thus making the latency extremely high at moments. The only way to get worst-case latency guarantees is to use full-blown realtime OS, however, even with a system like Linux you can do several things to to get realtime-like behaviour:

  • Recompile your kernel with kernel preemption on (either CONFIG_PREEPT=y or CONFIG_PREEMPT_VOLUNTARY=y and CONFIG_PREEMPT_BKL=y).
  • Use such a scheduling policy that gives OpenAMQ priority over other processes (say use round-robin scheduling).
  • Lock OpenAMQ into physical memory to avoid page faults.
  • Try experimenting with CPU affinities, CPU shielding etc.

Network interface card

You can lower latency by changing the settings of your NIC, if this is allowed.

  • If there's a possibility to set max. interrupt rate in your NIC, turn it off for best latency. Interrupts should be issued immediately after data are received.
  • Try experimenting with different settings of your NIC and chipsets. Many systems have various "accelerators" for network traffic that may or may not improve the latency.
  • Use direct connections instead of switched ones.


Add a New Comment

Edit | Files | Tags | Source | Print

rating: +4+x


Martin Sustrik <moc.xitami|kirtsus#moc.xitami|kirtsus>

All tutorials

Performance Tests: This tutorial explains how to do OpenAMQ performance tests using 0MQ performance testing framework.

Broker federation: How to setup a geographically distributed federation of OpenAMQ brokers and how to define dataflows between individual geographical locations.

The ESB cookbook: How to implement your own Enterprise Service Bus, step by step, using OpenAMQ.

Publishing contents: How to publish contents at high speed without bizarre memory issues.

Tuning OpenAMQ for low latency: How to tune your operating system and hardware to get the lowest latency, i.e. the best response times, from your OpenAMQ broker.

The mandatory and immediate flags: How to use the 'mandatory' and 'immediate' flags on the Basic.Publish method.

Load balancing: How to use OpenAMQ to distribute work between multiple applications, a technique called "load balancing".

Content based routing: How to route messages based on their header properties. It is a fast and simple way to do 'content based routing' without needing to inspect entire messages. We explain the principles and provide worked examples.

Transient or durable subscriptions: How to make subscriptions that are transient (come and go with their consuming applications) or durable (stay around).

The AMQ model: How the AMQ model works: this is a basic backgrounder for anyone starting to use OpenAMQ in their applications.

Developing on Windows: How to build OpenAMQ client applications using MSVC on Windows

Handling Ctrl-C in applications: How to properly detect an interrupt (Ctrl-C) and shut-down gracefully in C/C++ WireAPI applications.