Skip to content
Kafka Is Fun

BeginnerCore Concepts

What is the default log retention period in Kafka?

Reference answer

The default retention period is 7 days. At the broker level it comes from log.retention.hours, default 168; log.retention.minutes and log.retention.ms, if set, take precedence in that order (log.retention.ms defaults to null, so it is not what sets the 7 days). Per topic it can be overridden with retention.ms, whose default is 604800000 (7 days); -1 means no time limit. Size-based retention is off by default: retention.bytes (and log.retention.bytes) default to -1. Deletion happens one log segment at a time, and for time-based retention the largest timestamp in a segment decides the retention time of the whole segment, so a segment is only deleted once its newest record is past retention. If both time and size limits are set, a segment eligible under either one is deleted.

Expected key concepts: 7 days, 168, log.retention.hours, log.retention.ms, 604800000, retention.ms, retention.bytes, segment, largest timestamp

How did that feel?

Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.