gpt4 book ai didi

apache-kafka - 未使用的 Kafka 主题/分区的成本

转载 作者:行者123 更新时间:2023-12-04 16:27:45 27 4
gpt4 key购买 nike

在设计流处理管道时,如果我有许多主题,这些主题至少有一个分区但可能没有数据进入,可能会产生什么成本?

例如,对于一个消费者,我可以选择拥有一个包含所有数据和许多分区的“大型主题”,或者我可以选择将该数据(按租户、帐户或用户等)拆分为多个主题,默认情况下,单个分区。我对第二种情况的担心是会有很多主题/分区看不到数据。那么,这个未使用的分区是否会产生任何费用,或者未使用的主题是否会产生任何费用。

最佳答案

首先,一个胖主题和多个分区和多个主题包含几个分区没有区别。主题仅用于事件之间的逻辑区分。 Kafka 只关心分区的数量。

其次,有很多分区会导致一些问题:

  • 打开的文件太多:

  • Each partition maps to a directory in the file system in the broker. Within that log directory, there will be two files (one for the index and another for the actual data) per log segment.


  • 更多的分区需要更多的代理和消费者内存
    双方:

  • Brokers allocate a buffer the size of replica.fetch.max.bytes for each partition they replicate. If replica.fetch.max.bytes is set to 1 MiB, and you have 1000 partitions, about 1 GiB of RAM is required.


  • 更多的分区可能会增加不可用性:

  • 如果作为 Controller 的代理失败,那么zookeeper 会选择另一个代理作为 Controller 。 At that point newly elected broker should read metadata for every partition from Zookeeper during initialization.

    For example, if there are 10,000 partitions in the Kafka cluster and initializing the metadata from ZooKeeper takes 2 ms per partition, this can add 20 more seconds to the unavailability window.



    您可以从以下链接获得更多信息:
    https://www.confluent.io/blog/how-choose-number-topics-partitions-kafka-cluster/
    https://docs.cloudera.com/documentation/kafka/latest/topics/kafka_performance.html

    关于apache-kafka - 未使用的 Kafka 主题/分区的成本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59740832/

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