简体   繁体   中英

How can I reduce the 1s consumer lag in the Kafka Tutorial?

I'm working through the very first section of the Confluent Tutorials: https://kafka-tutorials.confluent.io/kafka-console-consumer-producer-basics/kafka.html . Everything works as described, but I notice there's about 1 second of lag between when I press enter in the producer terminal and when a message is displayed in the consumer terminal. Is it the producer or the consumer who's responsible for this lag/batching? Is there a way to configure things to be more responsive? A quick search turned up the linger.ms setting, but it seems like recent versions of Kafka default this setting to zero, and it doesn't appear to be overridden in these containers.

Ok, it looks like setting --timeout=0 in the producer makes the lag disappear. Looking at the kafka-console-producer source code , --timeout defaults to 1000 and gets merged into LINGER_MS_CONFIG . So even though linger defaults to zero in Kafka generally, it effectively defaults to 1 sec in this command line producer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM