使用比分区更多的消费者进行持续的消费者组重新平衡 [英] Continuous consumer group rebalancing with more consumers than partitions

查看:28
本文介绍了使用比分区更多的消费者进行持续的消费者组重新平衡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

鉴于以下设置:

  • Kafka v0.11.0.0
  • 3 个经纪人
  • 2 个主题,每个主题有 2 个分区,复制因子为 3
  • 2 个消费者组,每个主题一个
  • 3 个包含消费者的服务器

服务器包含两个消费者,每个主题一个,这样:

The servers contain two consumers, one for each topic such that:

  • 服务器 A
    • consumer-A1 在组 topic-1-group 消费 topic-1
    • consumer-A2 在组 topic-2-group 消费 topic-2
    • consumer-B1 在组 topic-1-group 消费 topic-1
    • consumer-B2 在组 topic-2-group 消费 topic-2
    • consumer-C1 在组 topic-1-group 消费 topic-1
    • consumer-C2 在组 topic-2-group 消费 topic-2

    在这种情况下,当我们检查 kafka-consumer-groups.bat 组 topic-1-group 的输出时,我们看到以下内容:

    In this scenario, when we examine the output of kafka-consumer-groups.bat for group topic-1-group, we see the following:

    • consumer-B1 被分配给 topic-1 partition-1
    • consumer-C1 被分配给 topic-1 partition-0
    • consumer-A1 未分配给任何分区

    这似乎与我们预期的一样.由于分区数为 2,我们只有两个活跃的消费者.第三个消费者只是闲置.我们能够很好地使用来自主题的消息.

    This appears to be as we would expect. Since the partition count is 2, we only have two active consumers. The third consumer is just idle. We are able to consume messages from the topic just fine.

    接下来,我们关闭服务器 B(主动分配给一个分区).这样做,我们会期望 topic-1-group 进入重新平衡,并期望消费者 A1 将取代消费者 B1 并被分配到一个分区,以便满足以下条件:

    Next, we shutdown Server B (who is actively assigned to a partition). Doing so, we would expect topic-1-group to enter rebalancing and expect that consumer-A1 would take the place of consumer-B1 and be assigned to a partition such that the following is true:

    • consumer-A1 被分配给 topic-1 partition-1
    • consumer-C1 被分配给 topic-1 partition-0
    • consumer-B1 没有被分配,因为它不再处于活动状态

    不过,我们看到的是消费者组 topic-1-group 进入了一种似乎没有停止的重新平衡状态.由于组处于重新平衡状态,心跳似乎也失败了.

    What we are seeing happen, though, is the consumer group topic-1-group enters a state of rebalancing that doesn't seem to stop. Heartbeats also seem to fail since the group is in rebalancing.

    从这种情况中恢复的唯一方法是关闭另一台服务器,以便 topic-1-group 只有一个消费者.当只有一个消费者时,我们能够成功接收该主题的消息.接下来,如果我们启动另外两台服务器,我们继续成功接收该主题的消息.

    The only way to recover from this is to shutdown another server so that there is only one consumer for topic-1-group. When there is only one consumer, we are able to successfully receive messages for the topic. Next, if we start up the other two servers, we continue to receive messages successfully for the topic.

    问题

    • 这是有效的使用场景吗?
    • 在这种情况下会发生什么?
    • 消费者会不会有问题?(在配置方面,除了设置主题、消费者组等基础知识外,我们对所有内容都使用默认值...我们使用 KafkaConsumer.subscribe(Collection) 而不是手动分配分区)
    • 经纪人/动物园管理员会不会有问题?

    推荐答案

    根据 Apache kafka confluent-如果您向组添加的使用者多于分区,那么一些使用者会保持空闲,因此理想情况下您不应该这样做

    As per Apache kafka confluent- if you add more consumer to a group than partition then some of the consumer remain idle so ideally you should not do that

    这篇关于使用比分区更多的消费者进行持续的消费者组重新平衡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆