Kafka Retention Policies: Time-based and Size-based
📖 Scenario: You are managing a Kafka topic that collects user activity logs. To keep the storage efficient, you want to apply retention policies that automatically delete old messages based on time and size.
🎯 Goal: Configure a Kafka topic with both time-based and size-based retention policies, then verify the configuration by printing the topic settings.
📋 What You'll Learn
Create a Kafka topic configuration dictionary with default settings
Add a time-based retention policy of 7 days (in milliseconds)
Add a size-based retention policy of 1 GB (in bytes)
Print the final topic configuration dictionary
💡 Why This Matters
🌍 Real World
Kafka topics often collect large amounts of data. Retention policies help manage storage by deleting old or excess data automatically.
💼 Career
Understanding Kafka retention policies is important for roles like data engineers, backend developers, and system administrators who manage data pipelines and streaming platforms.
Progress0 / 4 steps