Summary
This article explains how to tune your operating system and hardware to get the lowest latency, i.e. the best response times, from your OpenAMQ broker.
Problem
Tuning OpenAMQ means ensuring the broker runs without too many interruptions from the operating latency.
Explanation
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.
Comments
Author
- Martin Sustrik <moc.xitami|kirtsus#moc.xitami|kirtsus>

Running the amq server and client with tcmalloc instead of malloc produces a dramatic improvement in latency. In our environment, using tcmalloc reduced the median latency by 34%.