gpt4 book ai didi

java - 在 Apache Kafka 中保留数据

转载 作者:搜寻专家 更新时间:2023-11-01 02:25:05 25 4
gpt4 key购买 nike

几天前我刚刚开始阅读有关 Apache kafka 的内容,所以我是这项技术的新手。我有一些疑问/疑问,需要得到澄清。如:

  1. 根据配置:log.retention.hours 我们可以在这里设置持续时间(以小时为单位)。 数据保留时间能否延长2年?

  2. 根据这个link它说:

The Kafka cluster retains all published messages—whether or not they have been consumed—for a configurable period of time. For example if the log retention is set to two days, then for the two days after a message is published it is available for consumption, after which it will be discarded to free up space. Kafka's performance is effectively constant with respect to data size so retaining lots of data is not a problem.

正如它已经说过的那样,性能在数据大小方面实际上是恒定的。那么这是否意味着我们可以尽可能多地存储数据?它是否需要一些额外的配置或监视器?

最佳答案

1) 当然可以。 log.retention.hours 是一个整数。 2年就是17520小时。远低于整数的最大值。

2) 您可以存储适合您拥有的磁盘的尽可能多的数据。请注意,虽然如果您存储更多数据,Kafka 的性能不会降低,但尝试从磁盘获取大量数据的消费者绝对会影响性能。为获得最佳性能,请确保消费者读取相对较新的数据,同时这些数据仍保留在内存中。

关于java - 在 Apache Kafka 中保留数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26425513/

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