question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consumer has 500ms delay

See original GitHub issue

The problem make me annoying these days. We used consumer to consume data from kafka, and found its had 500ms delay at fixed-frequency. We checked all the configuration of librdkafka, and found nothing can reduce the delay. And then I add the event listener of event.log, and print the partition and offset of current received message to console. Then I found that the fetch event was almost 500ms before the consumer’s data on same partition and offset. There must be something prevent the consumer from returning the data received at once! So I check the code of node c++ and c. Finally, I found a piece of suspicious code: https://github.com/Blizzard/node-rdkafka/blob/8d2963bf21ed9b8a79ad5adabcec2362bc12392e/src/workers.cc#L450-L459

There is a magic number in the code, and it not indicated on the document, and not supply an option argument for developer to change it.

Sleep function would not make current thread busy, even you call it with 1ms, I think 500ms is not a optimal value as default.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Tapppicommented, Dec 5, 2019

Looks like the loop version of consume needs a similar optimisation to https://github.com/Blizzard/node-rdkafka/commit/e82bb2ea93d03e56ed9f1f1a1d2fdfaf22220d00#diff-d3b92fea9df0e70b4f0aed1821f7b6c9 . It is indeed likely that you are producing the message at such a point that the consumer is sleeping at that point. Looking at the code, there are multiple edge cases where that can happen either to the first new message or even during consuming already existing messages.

0reactions
yunnysunnycommented, Oct 29, 2020

The pull request https://github.com/Blizzard/node-rdkafka/pull/769 has been merged

Read more comments on GitHub >

github_iconTop Results From Across the Web

What Is Latency and How Do You Fix It? - Reviews.org
No one likes lag, and that's why we created this guide on how to fix high latency. Find out more about why latency,...
Read more >
Delaying some records in a Kafka topic - Stack Overflow
One problem with two consumers is that all messages would be read twice, not at the exact same time, which pose the issue...
Read more >
Kafka Consumer Important Settings: Poll & Internal Threads ...
Once the consumer is subscribed to Kafka topics, the poll loop handles all ... you will have up to 500 ms of latency...
Read more >
Response Time Limits: Article by Jakob Nielsen
10 seconds is about the limit for keeping the user's attention focused on the dialogue. For longer delays, users will want to perform...
Read more >
Tail Latency at Scale with Apache Kafka - Confluent
Kafka only exposes messages to the consumer after they have been committed, that is, replicated to all in-sync replicas for fault tolerance.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found