How to configure Kafka message deletion strategy?

The deletion strategy for Kafka messages can be configured using the following attributes:

  1. retention.ms: This property specifies the retention time of messages in the log. The default value is 7 days, but you can adjust this value as needed to set the retention time of messages.
  2. cleanup policy: this property specifies the deletion policy. There are several optional values to choose from:
  3. Delete: indicates that the message will be removed after the retention period expires.
  4. Compact: Messages will be compressed once they expire after the retention time, keeping only the latest updated message.
  5. delete and compact: indicates that messages will be both deleted and compressed.
  6. min.cleanable.dirty.ratio: This parameter specifies the minimum dirty data ratio before performing log cleaning (deletion or compression). The default value is 0.5, indicating that log cleaning will only be carried out when the dirty data ratio reaches 50%.

These properties can be configured in Kafka’s configuration file (e.g. server.properties). You can modify the values of these properties as needed and restart the Kafka Broker for the configuration to take effect.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds