The cleanup.policy config designates the retention policy applied to log segments: the default "delete" policy discards old segments when their retention time or size limit is reached, while "compact" enables log compaction, retaining the latest value for each key; both can be combined as a comma-separated list such as "delete,compact", and an empty list means infinite retention with no cleanup policies applied. Under the delete policy, retention.ms sets the maximum time a log is retained before old segments are discarded — it represents an SLA on how soon consumers must read their data, defaults to 604800000 (7 days), and -1 applies no time limit. retention.bytes caps the maximum size a partition can grow to before old segments are discarded; by default there is no size limit, only a time limit, and because the limit is enforced at the partition level it must be multiplied by the number of partitions to compute topic retention in bytes. Both operate independently of segment.ms and segment.bytes. With remote storage enabled, the local retention limits log.local.retention.ms and log.local.retention.bytes still apply to local segments. Scope: Apache Kafka. Reviewed October 4, 2026.
Retention with cleanup.policy, retention.ms, and retention.bytes
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- kafka.apache.org
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.