-
Notifications
You must be signed in to change notification settings - Fork 3.2k
How to decrease message latency
Aaron edited this page Nov 10, 2016
·
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 upfetch.min.bytes
worth of messages before responding. Setqueue.buffering.max.ms
to 1 here also could reduce the poll timeout and decrease the latency.
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.
You can also minimize socket.blocking.max.ms
for both producer and consumer.