Oh My Algorithm
Concept GuideAppend-only Log · Ordering

Topic & Partition

A Kafka topic isn't a queue — it's a log you only ever append to. The topic is split into partitions, each record is appended to the end of one, and the position it lands in becomes its offset. Multiple partitions mean parallel writes and reads, but ordering is only guaranteed inside a single partition. That's exactly why records sharing a key always land in the same one.

01 Concept at a Glance

Interactive Step-by-Step
Topic & Partition · Append-only Log
Partition 0
0
1
2
3
4
5
Partition 1
0
1
2
3
4
5
Partition 2
0
1
2
3
4
5

A Kafka topic isn't a queue, it's a log. One topic is split across partitions, and each partition is a single line you only ever append to.

Logic Node1 / 11

02 Understand It Simply

For Everyone
🔑Analogy

Like opening more bank counters. Throughput goes up, but there's no ordering between the queues. To process one customer's transactions in order, that customer must always go to the same counter — the same key to the same partition.

💡In Plain Words

Records are only appended to the end of a partition, never modified in place, which turns writes into sequential disk access and makes them fast.

Partition assignment comes from hashing the key; with no key, records are spread round-robin.

Adding partitions buys parallelism at the cost of any global ordering across the topic.

Consuming doesn't remove anything either — records stay for the retention period, so several consumers read the same data independently.

📍Where It's Used
  • Designing event-streaming pipelines
  • trading partition count against ordering guarantees
  • and using keys to group whatever must stay in order

03 Frequently Asked Questions

FAQ
What is Topic & Partition?+

A Kafka topic isn't a queue — it's a log you only ever append to. The topic is split into partitions, each record is appended to the end of one, and the position it lands in becomes its offset. Multiple partitions mean parallel writes and reads, but ordering is only guaranteed inside a single partition. That's exactly why records sharing a key always land in the same one.

Where is Topic & Partition used?+

Designing event-streaming pipelines, trading partition count against ordering guarantees, and using keys to group whatever must stay in order.

What's a simple analogy for Topic & Partition?+

Like opening more bank counters. Throughput goes up, but there's no ordering between the queues. To process one customer's transactions in order, that customer must always go to the same counter — the same key to the same partition.

Guide Progress0%