why kafka-console-producer only write message to 1 partition(topic has 3 partitions) instead of using round-robin algorithm?

huangapple go评论70阅读模式
英文:

why kafka-console-producer only write message to 1 partition(topic has 3 partitions) instead of using round-robin algorithm?

问题

我正在使用Kafka 3.3.2版本。我已经创建了一个具有3个分区的主题。从下面的截图中,我们可以看到有3个文件夹。

然后我使用kafka-console-producer向这个主题写入消息。消息的格式是{message+i}:
例如:message1,message2,message3等。

然而,当我检查日志文件时,我发现所有的消息都被发送到了/tmp/kafka-logs/my-partitioned-topic-0/00000000000000000000.log中的分区0。

在/tmp/kafka-logs/my-partitioned-topic-1/00000000000000000000.log中没有内容。

你知道原因吗?

谢谢解释。

英文:

I am using the kafka 3.3.2.
I have create one topic with 3 partitions.From the below screenshot we can see there are 3 folders
why kafka-console-producer only write message to 1 partition(topic has 3 partitions) instead of using round-robin algorithm?

Then I use the kafka-console-producer to write message to this topic. The messages are {message+i} format:
for example: message1, message2, message3 etc.

However when I check the log file I find that all the message are sent to partition0 in /tmp/kafka-logs/my-partitioned-topic-0/00000000000000000000.log

There is not content in /tmp/kafka-logs/my-partitioned-topic-1/00000000000000000000.log

Do you know the reason?

Thanks for explaination.

Please help me understand the reason

答案1

得分: 1

Kafka 使用黏性分区策略来处理非键记录,以解决将没有键的记录分散到较小批次的问题。
所以,我猜测你是在发送没有键的消息。
你可以在这里获取有关这些策略以及 Kafka 何时使用轮询的更多信息:文章链接

英文:

Kafka uses a Sticky partitioning strategy for non-keyed records to address the problem of spreading out records without keys into smaller batches.
So, i'm guessing that you are sending your messages without a key.
You can get more information on these strategy and when kafka uses Round-Robin in this: article

huangapple
  • 本文由 发表于 2023年3月9日 22:49:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75686209.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定