简体   繁体   English

为什么kafka 0.8.2说每个分区都由一个消费者组中的一个消费者完全消费

[英]Why kafka 0.8.2 say that each partition is consumed by exactly one consumer in a consumer group

In Apache Kafka 0.8.2 office document, section 5.6 Distribution , Consumers and Consumer Groups subsection, it says that 在Apache Kafka 0.8.2 Office文档的第5.6节“分发消费者和消费者组”小节中,该代码表示​​:

The consumers in a group divide up the partitions as fairly as possible, each partition is consumed by exactly one consumer in a consumer group. 组中的使用者尽可能公平地划分分区,每个分区仅由一个使用者组中的一个使用者使用。

But I have found that in practice, it is possible that multiple consumers in a consumer group can consuming data from a single partition by sending FetchRequest from the same topic-partition. 但是我发现,实际上,使用者组中的多个使用者可以通过从同一主题分区发送FetchRequest来使用单个分区中的数据。

And in the followed Consumer Id Registry subsection 在随后的消费者ID注册局小节中

In addition to the group_id which is shared by all consumers in a group, each consumer is given a transient, unique consumer_id (of the form hostname:uuid) for identification purposes. 除了组中所有使用者共享的group_id之外,还为每个使用者都提供了一个瞬态的,​​唯一的Consumer_id(格式为hostname:uuid)以用于标识。 Consumer ids are registered in the following directory. 消费者ID在以下目录中注册。

/consumers/[group_id]/ids/[consumer_id] --> {"topic1": #streams, ..., "topicN": #streams} (ephemeral node) / consumers / [group_id] / ids / [consumer_id]-> {“ topic1”:#streams,...,“ topicN”:#streams}(临时节点)

It says there is a unique id for each consumer. 它说每个消费者都有一个唯一的ID。 However, I could not found such structure in zookeeper. 但是,我在zookeeper中找不到这种结构。

I do not know when consumer start to register? 不知道消费者何时开始注册? The client library I used is kakfa-python 0.9.4. 我使用的客户端库是kakfa-python 0.9.4。

May this help 可能有帮助

(1) For your second question. (1)关于第二个问题。 https://github.com/dpkp/kafka-python/issues/472 And issue38 https://github.com/dpkp/kafka-python/issues/472和issue38

It said "Coordinated Consumer Group support is under development." 它说:“协调的消费者团体支持正在开发中。”

(2) For your first question. (2)第一个问题。

It said "This is achieved by assigning the partitions in the topic to the consumers in the consumer group so that each partition is consumed by exactly one consumer in the group. "(statement A). 它说:“这是通过将主题中的分区分配给消费者组中的消费者来实现的,以便每个分区都由组中的一个消费者完全消费。”(声明A)。 This depends on clients implements. 这取决于客户端工具。 This may be not right in some kafka clients. 在某些kafka客户中,这可能不正确。 I just have experience in python and cpp. 我只是有python和cpp的经验。 If group was implemented, each message is consumed by exactly one consumer in the group. 如果实施了分组,则每条消息仅由该分组中的一个使用者使用。 How to assign partitions between consumers in one group is different. 如何在一组消费者之间分配分区。 When there are more partitions than consumers, Statement A may be right. 当分区的数量超过使用者数量时,语句A可能是正确的。 But it is also possible that the partitions may be re-assigned when new partitions join or leave the existing group. 但是,当新分区加入或离开现有组时,也可能会重新分配分区。 In this case, partition A may be consumed by consumer A firstly and then consumed by consumer B, which is possible. 在这种情况下,分区A可以先由消费者A消费,然后再由消费者B消费,这是可能的。 In some clients, you can choose the assignment algorithms, such as round-robin, and so on. 在某些客户端中,您可以选择分配算法,例如循环调度等。

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

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