Monedula

Scenario 00.1.1 · Topic, partition, offset

Kafka topics, partitions and offsets explained

Anatomy · Beginner · about 2 min · Apache Kafka 4.3

A topic is split into partitions; each partition is an ordered log; an offset is a position within a partition.

Run this scenario in the playground

Each partition is an ordered log · offsets count up. t+1.700s

Six records total, two per partition. An offset is a record's position within its partition: each partition now holds offsets 0 and 1. Offsets are assigned per partition, always starting at 0.

Open at this step: step 3, Each partition is an ordered log · offsets count up

What you start with

A topic isn't a single queue - Kafka splits it into independent partitions, each an ordered, append-only log. Here a producer writes six keyed records to a 3-partition topic; watch each record land in one partition and take the next offset (its position within that log).

Step by step

  1. Topic ready · 3 empty partitions t+0.000s A topic is not one queue - 'orders' is split into 3 partitions. Each partition is an independent, append-only log. All three start empty at offset 0. Open at this step: step 1, Topic ready · 3 empty partitions
  2. First records land · one per partition t+1.050s Three records (keys A, C, F) each landed in a different partition, every one at offset 0. Where a record lands is decided by its key (see 00.1.3). Open at this step: step 2, First records land · one per partition
  3. Each partition is an ordered log · offsets count up t+1.700s Six records total, two per partition. An offset is a record's position within its partition: each partition now holds offsets 0 and 1. Offsets are assigned per partition, always starting at 0. Open at this step: step 3, Each partition is an ordered log · offsets count up

The takeaway

A record is addressed by topic + partition + offset: ordering is guaranteed within a partition, and an offset simply counts the appends to that one log.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=00.1.1" title="Kafka Simulator: Topic, partition, offset" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/topic-partition-offset/">Kafka topics, partitions and offsets explained</a></p>

Further reading

Apache Kafka documentation

More in Anatomy

All scenarios