Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between retention configuration offsets.retention.minutes and log.retention.minutes

What is the difference between the following two retention configurations?

  • offsets.retention.minutes
  • log.retention.minutes

I don't get how it differs or relate to each other. From my understanding, once the offset is removed, the record in the log is not accessible and vice versa. Is there something I have misunderstood?

like image 872
Nicolas Henneaux Avatar asked Feb 28 '18 10:02

Nicolas Henneaux


People also ask

What offset retention minutes?

offsets. retention. minutes allows you to move the offset back to the beginning if it isn't changed within a set period of time.

What is log retention in Kafka?

log.retention.hoursThe most common configuration for how long Kafka will retain messages is by time. The default is specified in the configuration file using the log. retention. hours parameter, and it is set to 168 hours, the equivalent of one week.

What is log retention check interval MS?

The time to keep a log file before deleting it. log.retention.check.interval.ms. 300000 (5 minutes) Broker level. The frequency in milliseconds that the log cleaner checks whether any log is eligible for deletion.

What is the purpose of retention period in Kafka cluster?

With retention period properties in place, messages have a TTL (time to live). Upon expiry, messages are marked for deletion, thereby freeing up the disk space. The same retention period property applies to all messages within a given Kafka topic.


1 Answers

The offset is a pointer to the most recent message that has been consumed by a consumer. So if you read 10 messages, the offset moves 10 places. offsets.retention.minutes allows you to move the offset back to the beginning if it isn't changed within a set period of time.

To visualise it, let's assume that we put the letters a to g (in that order) in a Kafka topic, all at different times. Before we start consuming the messages, the offset points to the oldest message:

OFFSET:    *
MESSAGES:  a b c d e f g

Now we consume 3 messages (a, b, c) so the offset moves:

OFFSET:          *
MESSAGES:  a b c d e f g

Now let's pretend we've set log.retention.minutes=10, and we put a and b into the topic 11 minutes ago, but the other messages were inserted more recently. We'd see:

OFFSET:          *
MESSAGES:      c d e f g

Now let's set offsets.retention.minutes=1, and pretend it has been 90 seconds since we last consumed anything. We'd see:

OFFSET:        *  
MESSAGES:      c d e f g

because c is now the oldest message on the topic (and the first that will be consumed).

like image 88
Ben Watson Avatar answered Oct 03 '22 23:10

Ben Watson