Reconnecting to Kafka using node -rdkafka is slow and inconsistent

I have kafka and zookeeper working in some local docker containers.

I have a node.js codebase that uses node -rdkafka to connect to kafka as a consumer. We will call this code base "consumer"

The consumer uses the code here to connect to the kafka: https://github.com/Blizzard/node-rdkafka/blob/master/examples/consumer-flow.md

When I try to connect to an existing Kafka instance, I get this output:

consumer ready.{"name":"rdkafka#consumer-1"}

But then my code, which receives and processes messages, never fires, or takes several minutes (apparently, 5 to 10 minutes) before it starts firing.

To ensure message creation, I use a script kafka-console-consumer.shthat comes with kafka to monitor the flow of messages. Of course, PLENTY data will appear.

It seems that the connection sometimes fails, and sometimes it takes a very long time to connect.

Here's the kafka magazine for this time:

kafka_1      | [2017-04-27 20:55:37,963] INFO [Group Metadata Manager on Broker 1001]: Removed 0 expired offsets in 1 milliseconds. (kafka.coordinator.GroupMetadataManager)
kafka_1      | [2017-04-27 20:55:48,576] WARN Attempting to send response via channel for which there is no open connection, connection id 1 (kafka.network.Processor)
kafka_1      | [2017-04-27 20:55:53,185] INFO [GroupCoordinator 1001]: Preparing to restabilize group video-caption-consumer with old generation 24 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 20:56:18,577] INFO [GroupCoordinator 1001]: Stabilized group video-caption-consumer generation 25 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 20:56:18,626] INFO [GroupCoordinator 1001]: Assignment received from leader for group video-caption-consumer for generation 25 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 20:58:24,951] INFO [GroupCoordinator 1001]: Preparing to restabilize group video-caption-consumer with old generation 25 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 20:58:51,643] INFO [GroupCoordinator 1001]: Stabilized group video-caption-consumer generation 26 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 20:58:51,648] INFO [GroupCoordinator 1001]: Assignment received from leader for group video-caption-consumer for generation 26 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 21:01:14,231] INFO [GroupCoordinator 1001]: Preparing to restabilize group video-caption-consumer with old generation 26 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 21:01:16,414] INFO [GroupCoordinator 1001]: Stabilized group video-caption-consumer generation 27 (kafka.coordinator.GroupCoordinator)
kafka_1      | [2017-04-27 21:01:16,419] INFO [GroupCoordinator 1001]: Assignment received from leader for group video-caption-consumer for generation 27 (kafka.coordinator.GroupCoordinator)

He simply repeats this pattern endlessly.

Ideas?

Why is this important, I used the kakfa-node module for a while; which had similar problems, although I cannot be sure that the same problem.

+4
source share

Source: https://habr.com/ru/post/1675859/


All Articles