SteelReed

Search

Search posts, questions…

Messaging & KafkaQuestion 5 / 21

Junior

What are topics, partitions and offsets in Kafka, and how long does Kafka keep messages?

Short answer

A topic is a named stream of events split into partitions; each partition is an ordered append-only log, and the offset is a record's position in that partition. Kafka doesn't delete on read: it keeps data by retention or compaction.

group A read to 4group B read to 1Topic ordersPartition 0: offsets 0–5Partition 1: offsets 0–3Consumer AConsumer B

3 points to say:

  1. A partition is an append-only log: the unit of parallelism and the unit of ordering; an offset only means something within one partition.
  2. Reading doesn't delete: consumers track their own offsets, so many groups read independently and can replay.
  3. Data goes away by retention (time/size) or compaction (latest value per key); segments make deleting old data cheap.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.