internalsGet Pro

Module 09 · Lesson 9 of 14Pro

Retention, compaction and replaying events

Level
Intermediate
Topic
Event streaming with Kafka
Reading time
18 min

When you finish this page you can

  1. Explain why Kafka deletes old data one segment file at a time, and size a topic’s disk from its rate, retention and replication factor.
  2. Decide whether a topic should be compacted, and set min.compaction.lag.ms and delete.retention.ms so its readers still see what they need.
  3. Replay a time window of a topic into a new consumer group with kafka-consumer-groups.sh, dry run first, without disturbing the live reader.
  4. Say what to do when the data you need is older than retention, and what tiered storage changes.

Builds on 3 lessons

Start with lesson 217 min
  1. Kafka in practice: topics, partitions and offsets17 min
  2. Kafka consumers: groups, commits and rebalancing17 min
  3. Case: Shopify’s CDC from a sharded monolith18 min

Friday morning, and a day of wrong counts

is an online store in India. Its apps send about 200 million click events a day to the Kafka topic kartly.clicks. One reader of that topic is product-views, a small Python service that counts product page views per minute for the merchandising team’s “trending now” list.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan