liveBook · Manning

Primary node

As explained in Kafka for Architects

A Kafka partition leader is the replica that coordinates writes for that partition and serves as the synchronization reference for follower replicas.

A Kafka partition has one primary replica, called its leader. Other replicas are followers. Leaders for different partitions can live on different brokers, distributing work across the cluster. This is a data role: a partition leader is not the active KRaft controller, which manages cluster metadata and broker coordination. section 2.3.1 section 1.3.2

A producer sends a message to the partition’s leader, not to every replica. Followers query the leader and pull new data asynchronously. That delay means the leader can hold messages that followers have not yet copied; replicas may therefore contain different amounts of data at a given moment. section 2.3.1

The leader’s role creates two practical design concerns:

  • Write reliability depends on replication, not merely on reaching the leader. An in-sync replica (ISR) has caught up with the leader; min.insync.replicas sets how many in-sync replicas must be available for a successful write. If too few are available, the producer receives an exception. section 2.3.1
  • Producers must locate the current leader. A client library requests and caches broker-to-partition-leader metadata. If leadership changes and a send reaches the former leader, the library refreshes metadata and resends the batch to the new leader. section 3.2

A write during a leadership change

A producer has cached the broker hosting a partition leader. Leadership changes before its next send, so the cached destination returns a temporary error. The client library obtains fresh metadata and retries against the newly selected leader. The application may see an informational log message rather than needing to route the batch itself. section 3.2

Figure 2.10 Each partition has one replica designated as the leader, while the others serve as followers.
A screenshot of a black background

Description automatically generated

The partition layout shows one leader alongside its followers, making clear that leadership belongs to a partition replica rather than to every broker as a whole. section 2.3.1

How Kafka for Architects covers it

How deep it goes
Explains replica placement, asynchronous replication, in-sync replicas, and producer rerouting; defers detailed reliability strategies.
Examples
Uses a leader-and-follower partition diagram and a producer whose cached leader metadata becomes stale after a leadership change.
What it assumes
Assumes familiarity with topics, partitions, brokers, and producers while defining leader and follower replica roles.
What you can do after
Diagnose/debug with it when producer sends encounter a former leader or writes fail because too few in-sync replicas are available.
How it connects
Links partition leaders to follower replicas, in-sync replicas, producer metadata, and KRaft controllers as a distinct cluster role.

Also explained in

Compare how 4 books explain primary node →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.