Commit LogTopicsPartitionsOffsetsRecordsLog CompactionRetentionKeys

Kafka Core Architecture

Kafka is not a message queue — it's a distributed commit log. Understand topics, partitions, offsets, and records before anything else.

40 min read9 sections
01

What is Kafka & Why It Exists

Kafka is widely misunderstood as "just a message queue." It is not. Kafka is a distributed commit log — an append-only, immutable, ordered sequence of records that multiple consumers can read independently at their own pace.

Traditional (RabbitMQ, SQS) delete messages after a consumer acknowledges them. Kafka retains messages for a configurable period regardless of consumption. This single design decision unlocks replay, , and independent consumer groups — capabilities that fundamentally change system architecture.

📜

The Newspaper vs The Phone Call

A traditional message queue is like a phone call — once the message is delivered, it's gone. If you weren't listening, you missed it. Kafka is like a newspaper archive. Every event is printed and stored in order. Any reader can start from today's edition, last week's, or the very first issue. Multiple readers can read the same archive independently without affecting each other. The archive is retained for a configurable period (or forever with compaction).

The Three Roles Kafka Plays

📨 Message Queue

  • Decouples producer from consumer
  • Absorbs traffic spikes
  • for load balancing

🌊 Event Streaming

  • Real-time stream processing
  • Kafka Streams / integration
  • Windowed aggregations

💾 Storage Layer

  • Source of truth (event log)
  • Replay from any offset
  • Log compaction for latest state

Kafka vs Traditional Message Queues

AspectTraditional Queue (RabbitMQ/SQS)Kafka
Message retentionDeleted after acknowledgmentRetained for configurable period (days/weeks/forever)
Consumer modelPush-based, competing consumersPull-based, consumer groups with independent offsets
ReplayNot possible — message is goneAny consumer can seek to any offset and replay
OrderingBest-effort (per-queue in SQS FIFO)Guaranteed within a partition
ThroughputThousands/sec (broker bottleneck)Millions/sec (partitioned, sequential I/O)
Multiple consumersRequires separate queues or fan-out exchangesMultiple consumer groups read same topic independently
Best forTask queues, RPC, simple decouplingEvent streaming, event sourcing, high-throughput pipelines

🔑 The Key Insight

Kafka's fundamental innovation is treating messages as a durable, ordered log rather than a transient queue. This means the same data can serve multiple purposes: real-time processing, batch analytics, audit trails, and system recovery — all from the same stream.

1 / 9