Kafka-日志压缩行为 [英] Kafka - Log compaction behavior

查看:70
本文介绍了Kafka-日志压缩行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解日志压缩.

对于一个主题,我的设置是

For a topic, my settings are

min.cleanable.dirty.ratio   0.005
segment.ms  5000
cleanup.policy  compact

我在下面显示了该主题的消息

I produced below messages to the topic

a   0
b   1
c   1
f   4
r   0
s   1
u   1
f   5
h   1

我正在尝试通过kafka控制台使用者(即使在等待5分钟并创建了新的控制台使用者之后)进行使用者-我仍然看到2次出现的 f

I am trying to consumer via kafka console consumer (even after waiting 5 mins and created a new console consumer) - i still see the 2 occurrences of f

a   0
b   1
c   1
f   4
r   0
s   1
u   1
f   5
h   1

是否应将其删除?

推荐答案

在压缩过程中只能考虑不在活动段中的消息.即使您设置 segment.ms = 5000 ,当出现用于分区的新消息时,也可以滚动新的日志段.

Only messages that are not in active segment can be consider in compaction process. Even if you set segment.ms= 5000, rolling new log segment can be made when new messages for partition appear.

如果您一次发送所有消息 ,则所有消息都将进入同一网段,并且该网段将处于活动状态.如果新消息将在5000ms之后到达,则压缩变得有效. log.retention.check.interval.ms 之后的日志清理程序将尝试使用相同的键来压缩消息.

If you send all message at once, all messages will go to the same segment and that segment will be active. It became valid for compaction if new messages will arrive after 5000ms. Log cleaner after log.retention.check.interval.ms will try to compact messages with same key.

这篇关于Kafka-日志压缩行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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