gpt4 book ai didi

apache-kafka - Kafka - 主题 & 分区 & 消费者

转载 作者:行者123 更新时间:2023-12-04 04:11:24 32 4
gpt4 key购买 nike

只想正确理解基础知识。

假设我有一个名为“myTopic”的主题,它有 3 个分区 P0、P1 和 P2。这些分区中的每一个都有一个领导者,并且该主题的数据(消息)分布在这些分区中。

<强>1。生产者将始终根据代理上的负载以循环方式写入分区的领导者。是这样吗?

<强>2。生产者如何知道分区的领导者?

<强>3。阅读特定主题的消费者是否应该阅读该主题的所有分区?对吗?

感谢您的帮助。

最佳答案

  1. Producer will always writes to the leader of the partition in a round robin fashion based on the load on the broker. Is that right?

默认情况下,是。

也就是说,生产者还可以决定使用自定义分区方案,即写入分区数据的不同策略。

  1. How do the producer know the leader of the partition?

通过 Kafka 协议(protocol)。

  1. Consumer reading a particular topic should read all partitions of that topic? Is that correct?

默认情况下,是。

也就是说,您还可以实现例如实现自定义逻辑的消费者应用程序,例如一个“采样”消费者,它只从 N 个分区中读取 1 个。

关于apache-kafka - Kafka - 主题 & 分区 & 消费者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44041110/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com