简体   繁体   English

卡夫卡分区和生产者关系

[英]kafka partition and producer relationship

I have a kafka cluster with three brokers and one topic with replication factor of three and three partitions. 我有一个带有三个代理的kafka集群,一个主题具有三个和三个分区的复制因子。 I can see that every broker has a copy of log for all partitions with the same size. 我可以看到,每个代理都为具有相同大小的所有分区提供了一个日志副本。 There are two producers for this topic. 此主题有两个生产者。

One day I reduced writing volume of one producer by half. 有一天,我将一位制作人的写作量减少了一半。 Then I found that all three brokers' inbound traffic reduced which is expected, but only partition 1's leader node's out traffic reduced which I don't understand. 然后,我发现所有三个代理的入站流量都减少了,这是预期的,但是只有分区1的领导节点的出站流量减少了,我不了解。

The partition leader's outbound traffic reduced because of replication. 由于复制,分区负责人的出站流量减少了。 But each broker is the leader of one partition, why only one leader's outbound traffic reduced? 但是每个经纪人都是一个分区的领导者,为什么只减少一个领导者的出站流量? Is it possible that the producer only writes content to one partition? 生产者可能只将内容写入一个分区吗? while I don't think so. 虽然我不这么认为。

Please help me explain it. 请帮我解释一下。 The cluster is working fine now, but I need to understand it in case of potential problem. 集群现在工作正常,但是如果有潜在问题,我需要了解它。 入站流量 出站流量

Assuming you are using Default Partitioner for KafkaProducer, which means two events with the same key are guaranteed to be sent to the same partition. 假设您使用的是KafkaProducer的默认分区程序,这意味着可以确保将具有相同密钥的两个事件发送到同一分区。

From From Kafka Documentation 来自卡夫卡文档

All reads and writes go to the leader of the partition and Followers consume messages from the leader just as a normal Kafka consumer would and apply them to their own log. 所有读取和写入都将到达分区的领导者,而追随者会像普通的Kafka使用者一样消耗来自领导者的消息,并将其应用于自己的日志中。

You could have reduced data ( from a producer) by skiping specific key or set of Keys, which could means no data to particular partition. 通过跳过特定键或一组键,您可能减少了数据(来自生产者),这可能意味着没有数据指向特定分区。

This answers why leader's outbound traffic reduced (No records for followers to consume) 这回答了为什么领导者的出站流量减少了(没有记录供追随者使用)

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

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