Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
All topics/Message Queues & Event Streaming
DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC

Kafka Partitions, Consumer Groups & Ordering

Scale parallel consumption while preserving per-key event ordering.

IntermediatePart of Message Queues & Event Streaming
Practice in AI HLD
Subtopics in Message Queues & Event Streaming (2)
OverviewKafka PartitionsAt-Least-Once & DLQ

In plain words

A Kafka topic is a highway with P lanes (partitions). Cars for the same user_id always stay in the same lane so they arrive in order, and each lane can have its own toll booth (consumer) running in parallel.

Think of it like…

Grocery store with 6 checkout lanes: keeping one family’s items in one lane preserves order while 6 lanes run in parallel.

Loading interactive diagram
Loading interactive exercise

Theory & how it works

Ordering is per-partition, NOT global

Kafka guarantees strict order *within a single partition*, not across partitions. Always use an entity ID like order_id or user_id as the partition key so OrderCreated and OrderCancelled land on the same partition in exact order.

Key points & practical guide

Summary checklist

  • Ordering holds within each partition, not across the whole topic
  • Max active consumers in a group = partition count
  • Different consumer groups track independent offsets (can replay history)

When to use it

  • Event-driven microservices, CDC, activity feeds, real-time pipelines

Watch out for

  • Adding 10 consumers to a 2-partition topic - 8 consumers will sit completely idle!

Quick check

Loading quiz
Parent topic
Message Queues & Event Streaming
Next subtopic
Delivery Guarantees & Dead-Letter Queues (DLQ)