Skip to content

How to decrease message latency

haosdent edited this page Jun 5, 2015 · 13 revisions

There are two builtin end-to-end latencies in librdkafka (or any consumer worth its name):

  • Producer batch latency - queue.buffering.max.ms - how long the producer waits for more messages to be .._produce()d by the app before sending them off to the broker in one batch of messages.
  • Consumer batch latency -fetch.wait.max.ms - how much time the consumer gives the broker to fill up fetch.min.bytes worth of messages before responding.

When trying to minimize end-to-end latency it is important to adjust both of these settings:

  • queue.buffering.max.ms - set to 1 (0 is an illegal value here).
  • fetch.wait.max.ms - set to your allowed maximum latency, e.g. 10 (ms).

Setting fetch.wait.max.ms too low (lower than the partition message rate) causes the occassional FetchRequest to return empty before any new messages were seen on the broker, this in turn kicks in the fetch.error.backoff.ms timer that waits that long before the next FetchRequest. So you might want to decrease fetch.error.backoff.ms too.