How to know the right value of log.retention.hours ? according to the disk size or other?

edited January 2019 in Kafka

Cluster include 3 kafka machines and each kafka have disk with 5 T.we found that all kafka disks was with 100% size , so kafka disk was full and this is the reason that all kafka brokers was failed

df -h /kafka
Filesystem Size Used Avail Use% Mounted on
/dev/sdb 5T 5T 13M 100% /var/kafka
After investigation we saw that log.retention.hours=10 days

So seems that purging is after 10 days and maybe this is the reason that kafka disks are full with 100% even if they are huge 5T

We want to know how to avoid full used capacity on kafka disks

What we need to set in Kafka config in order to purge the kafka disk according to the disk size \96 is it possible ?

And how to know the right value of log.retention.hours ? according to the disk size or other?



  • In Kafka, there are two types of log retention; size and time retention. The former is triggered by log.retention.bytes while the latter by log.retention.hours.

    In your case, you should pay attention to size retention that sometimes can be quite tricky to configure. Assuming that you want a delete cleanup policy, you'd need to configure the following parameters to

    Then you need to think about the configuration of log.retention.bytes, log.segment.bytes and To do so, you have to take into consideration the following factors:

    log.retention.bytes is a minimum guarantee for a single partition of a topic, meaning that if you set log.retention.bytes to 512MB, it means you will always have 512MB of data (per partition) in your disk.

    Again, if you set log.retention.bytes to 512MB and to 5 minutes (which is the default value) at any given time, you will have at least 512MB of data + the size of data produced within the 5 minute window, before the retention policy is triggered.

    A topic log on disk, is made up of segments. The segment size is dependent to log.segment.bytes parameter. For log.retention.bytes=1GB and log.segment.bytes=512MB, you will always have up to 3 segments on the disk (2 segments which reach the retention and the 3rd one will be the active segment where data is currently written to).

    Finally, you should do the math and compute the maximum size that might be reserved by Kafka logs at any given time on your disk and tune the aforementioned parameters accordingly. Of course, I would also advice to set a time retention policy as well and configure log.retention.hours accordingly. If after 2 days you don't need your data anymore, then set log.retention.hours=48.

Sign In or Register to comment.