保留配置 offsets.retention.minutes 和 log.retention.minutes 之间的区别 [英] Difference between retention configuration offsets.retention.minutes and log.retention.minutes

查看:99
本文介绍了保留配置 offsets.retention.minutes 和 log.retention.minutes 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下两种保留配置有什么区别?

What is the difference between the following two retention configurations?

  • offsets.retention.minutes
  • log.retention.minutes

我不明白它有什么不同或相互关联.据我了解,一旦offset被移除,日志中的记录就无法访问,反之亦然.我有什么误解吗?

I don't get how it differs or relate to each other. From my understanding, once the offset is removed, the record in the log is not accessible and vice versa. Is there something I have misunderstood?

推荐答案

偏移量是指向消费者已消费的最新消息的指针.因此,如果您阅读 10 条消息,则偏移量移动 10 位.offsets.retention.minutes 允许您将偏移量移回开始,如果它在设定的时间段内没有改变.

The offset is a pointer to the most recent message that has been consumed by a consumer. So if you read 10 messages, the offset moves 10 places. offsets.retention.minutes allows you to move the offset back to the beginning if it isn't changed within a set period of time.

为了将其可视化,假设我们将字母 ag(按此顺序)放在 Kafka 主题中,所有时间都不同.在我们开始消费消息之前,偏移量指向最旧的消息:

To visualise it, let's assume that we put the letters a to g (in that order) in a Kafka topic, all at different times. Before we start consuming the messages, the offset points to the oldest message:

OFFSET:    *
MESSAGES:  a b c d e f g

现在我们消耗了 3 条消息(abc)所以偏移量移动了:

Now we consume 3 messages (a, b, c) so the offset moves:

OFFSET:          *
MESSAGES:  a b c d e f g

现在假设我们已经设置了 log.retention.minutes=10,我们将 ab 放入主题 11 分钟之前,但最近插入了其他消息.我们会看到:

Now let's pretend we've set log.retention.minutes=10, and we put a and b into the topic 11 minutes ago, but the other messages were inserted more recently. We'd see:

OFFSET:          *
MESSAGES:      c d e f g

现在让我们设置 offsets.retention.minutes=1,并假设距离我们上次消费任何东西已经过去了 90 秒.我们会看到:

Now let's set offsets.retention.minutes=1, and pretend it has been 90 seconds since we last consumed anything. We'd see:

OFFSET:        *  
MESSAGES:      c d e f g

因为 c 现在是主题上最旧的消息(也是第一个将被消费的消息).

because c is now the oldest message on the topic (and the first that will be consumed).

这篇关于保留配置 offsets.retention.minutes 和 log.retention.minutes 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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