简体   繁体   English

卡夫卡多个制片人写同一主题?

[英]Kafka multiple producer writing to same topic?

Say I have a topic T1 with 3 partitions ie P1,P2 and P3. 说我有一个带有三个分区的主题T1,即P1,P2和P3。 Where p1 is leader and rest are followers. p1是领导者,其余是跟随者。

Now there are 2 producers want to push to same topic T1. 现在有2个生产者希望推送到同一主题T1。 I believe P1 will be leader for both of them ? 我相信P1将是他们两个的领导者? Also single offset will be maintained for both of them or offset is maintainer per partition per producer ? 还要为它们两个都保留单个偏移量,还是每个生产者每个分区的偏移量维护者?

Now I have single consumer which is polling from T1. 现在我有一个从T1进行轮询的单一消费者。 Will it get messages from both producers by default or it has to explicitly mention producer name if it wants message from specfic producer ? 它会默认从两个生产者那里获取消息吗,还是要从特定生产者那里获取消息时必须明确提及生产者名称?

Leader is not dependent on the producers or consumers, so p1 will be always returned as a leader. 领导者不依赖生产者或消费者,因此p1将始终作为领导者返回。 Offsets are not important for producers, they are defined per consumer group. 偏移量对于生产者而言并不重要,它们是针对每个消费者组定义的。 Offset determines, which messages were read and committed by a consumer group. 偏移量确定使用者组读取并提交了哪些消息。

Consumer will always read all the messages, it does not matter, which producer published them. 消费者将始终阅读所有消息,这无关紧要,哪个生产者发布了它们。

You're maybe mixing up replicas and partitions. 您可能正在混淆副本和分区。 When you say you have a topic with 3 partitions, it means your records will be dispatched amongs them according to the record key ( or dispatcher algo) . 当您说您的主题有3个分区时,这意味着您的记录将根据记录键(或调度程序算法)在其中进行调度。 There is no ' leader partition' . 没有“领导分区”。 However you have a leader broker that handle a partition. 但是,您有一个负责处理分区的领导者经纪人。 In your case you will have 3 leaders, each of them managing one of your 3 partitions. 在您的情况下,您将有3个领导者,每个领导者管理您3个分区之一。

An interstingng post here, regarding Kafka partitions: 关于Kafka分区的一篇有趣的文章:

Understanding Kafka Topics and Partitions 了解Kafka主题和分区

Yannick 亚尼克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM