The broker setting log.roll.ms defines the default maximum age of a Kafka log segment before Kafka creates a new one. Topics can override this default with segment.ms; Kafka also rolls a segment when it exceeds segment.bytes, 1 GiB by default. section 8.3.4
Rolling segments regularly makes retention more precise because Kafka deletes whole segments. A message can therefore remain longer than retention.ms while its segment continues receiving messages; segment.ms and retention.ms must be chosen together, with the retention-check interval also considered. section 10.3.1
Force a short roll interval for testing
Set a topic-specific interval of 60 seconds, produce messages, and inspect the partition directory. New log, index, time-index, and snapshot files show that Kafka created another segment. The broker-wide equivalent is log.roll.ms; the example uses segment.ms so it affects only the selected topic. section 8.3.4
Figure 8.4 Topics are divided into partitions. Partitions create segments as messages are produced. Segments consist of the actual log files, index files, and a snapshot file.
Trace how produced messages become partition segments containing log, index, and snapshot files. section 8.3.4
