With RocketMQ -- deletion of expired files , kafka will also periodically clean up files.

When the Broker starts, it starts a scheduled task, delays it for 30s, and then starts to determine the release to delete expired files every 5 minutes.

image.png

When the task starts, it will traverse all Segment files.

By default, only 7 days old files are kept. The judgment time is judged by the maximum timestamp largestTimestamp in the Segment file, not the modification time of the file.

image.png

If all segment files have been deleted, a new segment file needs to be created.

image.png

If there are currently multiple segment files, if the total size of these segment files exceeds the set threshold, assuming it exceeds 2.5G, and each segment file is 1G, then 3 segment files need to be deleted to ensure the segment. The total size of the files is less than the set threshold.

As above, if all segment files are deleted, a new segment file needs to be created.

image.png


大军
847 声望183 粉丝

学而不思则罔,思而不学则殆