-
Notifications
You must be signed in to change notification settings - Fork 3.2k
How to decrease message latency
Magnus Edenhill edited this page Sep 26, 2019
·
13 revisions
Also read the manual's chapter on low latency.
There are two builtin end-to-end latencies in librdkafka:
- Producer batch latency -
queue.buffering.max.ms
(aliaslinger.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 upfetch.min.bytes
worth of messages before responding.
When trying to minimize end-to-end latency it is important to adjust both of these settings:
- producer:
queue.buffering.max.ms
- set to 0 for immediate transmission, or some other low reasonable value (e.g. 5 ms) - consumer:
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.
In librdkafka <=0.9.2, or on Windows, you'll also want to minimize socket.blocking.max.ms
for both producer and consumer.