Consumer takes 30 seconds for first message
See original GitHub issueConsumer code:
await this.abisConsumer.connect()
// Subscribe can be called several times
await this.abisConsumer.subscribe({ topic: 'abis', fromBeginning: true })
let startTime = performance.now()
this.abisConsumer.run({
eachMessage: async ({ /*topic, partition,*/ message }) => {
console.log(`Took ${Math.round(performance.now() - startTime)} to execute`)
console.log({
key: message.key,
value: message.value
})
},
})
await this.abisConsumer.seek({ topic: 'abis', partition: 0, offset: 0 })
Only retrieving 6 messages and here is the output
Took 30827 to execute
{ key: null,
value:
<Buffer 7b 22 70 72 65 73 65 6e 74 22 3a 74 72 75 65 2c 22 62 6c 6f 63 6b 5f 6e 75 6d 22 3a 39 33 36 2c 22 61 63 63 6f 75 6e 74 22 3a 22 65 6f 73 69 6f 22 2c ... > }
Stuck on
{"level":"INFO","timestamp":"2019-02-05T21:21:27.618Z","logger":"kafkajs","message":"[Consumer] Starting","groupId":"deserialize-abis"}
The delay appears to be in joining the consumer group. However, the issue is only seen from kafkajs, works fine using command-line kafkacat
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (5 by maintainers)
Top Results From Across the Web
Kafka: Intermittent slowness when consuming first message ...
0.1. The first time I start up my application it takes 20-30 seconds to retrieve the "latest" message from the topic. I've used ......
Read more >5 Common Pitfalls When Using Apache Kafka - Confluent
1. Setting request.timeout.ms too low ... request.timeout.ms is a client-side configuration that defines how long the client (both producer and ...
Read more >Chapter 4. Kafka Consumers: Reading Data from Kafka
If a consumer crashed and stopped processing messages, it will take the group coordinator a few seconds without heartbeats to decide it is...
Read more >Amazon SQS visibility timeout - Amazon Simple Queue Service
To prevent other consumers from processing the message again, Amazon SQS sets a visibility ... The default visibility timeout for a message is...
Read more >Consumers - RabbitMQ
In that case first deliveries will happen when new messages are enqueued. ... Consumers are meant to be long lived: that is, throughout...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @dmoena, ideally, you want to take advantage of automatic rebalances. When using manual assignment you end-up rebuilding most of what’s already in Kafka. I would say that a manual assignment should only be used in special cases.
The most common issue is when the group has to rebalance and the old consumers won’t acknowledge the rebalance, for example, the consumer fetches a big batch and have a long heartbeat configured, which means that the consumer won’t be aware of any changes in the group until it heartbeats or fetches the next batch. You can see early indications of this problem on your logs (
Member <ID> in group test-group has failed, removing it from the group
), this means that the group probably failed to heartbeat on a given interval and was kicked out of the group, triggering a new rebalance. This can indeed cause long rebalances but I would say Kafka is working as intended here.Hi @jafri, are you using the same
groupId
of another consumer group? Because this time is influenced by the number of consumers in the group and their ability to stop processing and re-sync. Can you run your example withKAFKAJS_LOG_LEVEL=debug
so we can see what’s happening, this process should be fast.I run the example we have in the repo and it took some ms to join the group: