Kafka Fundamentals Explained with 80 Hand-Drawn Diagrams
This article introduces Kafka fundamentals using 80 hand-drawn diagrams, covering its pub-sub model, horizontal scalability, key concepts like topics, partitions, offsets, architecture with ZooKeeper and brokers, replication with leader/follower and ISR, and notes on KRaft mode replacing ZooKeeper in Kafka 4.0.
Reading font

Objective
In this series we will learn Kafka basics, message delivery semantics and how to configure them, plus Spark-Kafka integration and optimizations. This first article covers Kafka fundamentals.
Problem Background
Typical challenges that Kafka addresses:
Integrating many heterogeneous data sources and target systems, which introduces complexity around protocols and message formats.
Needing a messaging system capable of handling massive data streams.
Use Cases
Common scenarios include:
Stream processing
User activity tracking, log aggregation
System decoupling
What Is Kafka?
Kafka is a horizontally scalable, fault-tolerant, high-performance messaging system. It uses a publish-subscribe (Pub-Sub) model allowing multiple producers and consumers to write and read messages, thereby decoupling source and target systems.
Key characteristics:
Horizontal scaling to hundreds of nodes
High throughput: millions of messages per second
Real-time processing: latency as low as ~10 ms
Key Terminology
Topic, Partition, Offset
A Topic is a specific data stream, analogous to a table in a NoSQL database.
Like a database table, a Topic can be split into multiple Partitions to distribute data across nodes for distributed storage.
Similar to a primary key, each Partition has its own independent Offset (offset).
Together, Topic, Partition, and Offset uniquely identify a message.
Partition Details
Partitions enable a Topic to be distributed across multiple cluster nodes. They are the basic unit for parallel processing and horizontal scaling. A Topic can contain many Partitions spread across different nodes, boosting parallelism and overall scalability.
Messages are assigned to partitions based on a partition key; if no key is provided, assignment is random. Choosing a good partition key is critical to avoid hot partitions and data skew.
Each message in a partition receives an incrementing ID called the Offset. Offsets are unique per partition; ordering is guaranteed only within a partition, not globally across the Topic. Messages are immutable once written.
Kafka Architecture
The diagram below illustrates Kafka's architecture.
ZooKeeper
ZooKeeper is a centralized service for managing distributed systems, providing hierarchical key-value storage, configuration management, synchronization, and naming registration.
It acts as the coordination layer, connecting components and ensuring high availability of the Kafka cluster. Kafka nodes are called Brokers.
Important: Kafka cannot run without ZooKeeper in the traditional architecture.
In a ZooKeeper ensemble, one node is elected Leader (others are Followers). If a node fails, a new Leader is elected from the remaining Followers. ZooKeeper uses a quorum (majority) mechanism, so an odd number of nodes (1, 3, 5, 7) is typical; more than 7 is not recommended.
ZooKeeper stores Kafka cluster metadata and state: topic names, partition counts, replica configs, partition leader info, consumer group info, etc. Think of it as a project manager coordinating resources and recording state.
Note: The above describes the classic ZooKeeper-based architecture. Since Kafka 2.8, KRaft mode was introduced to gradually remove ZooKeeper dependency; from Kafka 4.0 onward, ZooKeeper mode has been removed.
Key ZooKeeper responsibilities:
Manage Broker list
Elect new Leader when a Broker fails
Send notifications on Broker joins, topic creation/deletion, Broker loss
Since Kafka 0.10, consumer offsets are no longer stored in ZooKeeper; it holds only cluster metadata
Leader ZooKeeper handles all writes; Followers handle reads
Broker
A Broker is an independent node in the Kafka cluster, managed by ZooKeeper. Multiple Brokers form a cluster.
Topics are distributed across Brokers according to partitions and replication factors.
When a Broker fails, Kafka rebalances the cluster using ZooKeeper state. If a partition's Leader replica fails, a new Leader is elected from its Followers to continue serving reads and writes.
Analogy: a Broker is like a team lead handling assigned tasks; if unavailable, the manager (ZooKeeper) reassigns tasks.
Replication
Replication copies a Partition to other Brokers, giving Kafka fault tolerance.
When a Topic's Partition is stored on multiple Brokers, one replica becomes Leader, others are Followers.
Replication allows Kafka to serve requests even when a Broker fails.
Example: Topic B's Partition 0 resides on Broker 1 and Broker 2. Producers and Consumers interact only with the Leader replica.
If a Broker fails, Kafka elects a new Leader from the remaining replicas to continue serving the producer and consumer groups.
Replicas that stay in sync with the Leader are marked as ISR (In-Sync Replicas).
IT Team vs. Kafka Cluster Analogy
The following diagram maps IT team roles to Kafka components.
Summary
Core Kafka components:
ZooKeeper : Manages Kafka Brokers and their metadata.
Broker : Cluster node, horizontally scalable, stores Topics and replicas.
Topic : Message stream composed of one or more Partitions.
Partition : Stores messages; each message has a unique Offset within its Partition.
Replication : Follower replicas provide fault tolerance.
In the next part of this series, I will cover Producer, Consumer, Consumer Group, delivery semantics (At-Most-Once, At-Least-Once, Exactly-Once) and their configurations.
For questions about attribution, corrections or content rights, please contactand we will review it promptly.