liveBook · Manning

Primary node

As explained in Apache Kafka in Action

A Kafka partition leader is the broker responsible for handling reads and writes for a partition.

A Kafka partition has one leader broker: the primary node responsible for its reads and writes. In a bank-transfer stream, producers send transfer events to a topic divided into partitions. Each partition’s leader handles its share of that traffic, allowing work to be spread across brokers. section 1.3

The leader is one of the partition’s replicas. With a replication factor of three, a partition normally has one leader and two followers. Followers fetch new messages from the leader; if the leader fails, a follower can take over. Leaders are distributed across brokers rather than concentrated on one server. section 4.2.3 section 1.3

Find the leader of a partition

Run `kafka-topics.sh --describe --topic products.prices.replication --bootstrap-server localhost:9092`. In the three-partition example, partition 0 reports `Leader: 2`, partition 1 reports `Leader: 3`, and partition 2 reports `Leader: 1`. `Replicas` lists brokers storing each partition; `Isr` lists those currently in sync. A shorter `Isr` list than `Replicas` signals that a replica may be lagging or a broker may have failed. section 4.2.3

A producer or consumer need not start by connecting to the correct leader. It connects to a bootstrap broker, requests metadata identifying partition leaders, then uses that information to reach the responsible brokers. For production bootstrap settings, provide multiple brokers so a client can still start if one is down. section 7.4 section 9.1

The leader also determines when a producer receives an acknowledgment. With `acks=all`, it waits until all in-sync replicas have the message. With `acks=1`, it acknowledges receipt sooner, but a failure before followers fetch the message can lose it. With `acks=0`, the producer waits for no acknowledgment. Choose this setting with the required reliability and latency in mind. section 5.1.1 section 8.2

How Apache Kafka in Action covers it

How deep it goes
Explains leader–follower replication, metadata discovery, and acknowledgment choices; leaves detailed broker storage mechanics outside the leader definition.
Examples
Uses a bank-transfer topic and `kafka-topics.sh --describe` output showing leaders on three different brokers.
What it assumes
Introduces brokers, topics, and partitions before explaining leaders; assumes no prior Kafka knowledge for the architectural overview.
What you can do after
Diagnose/debug with it by locating a partition leader, checking in-sync replicas, and relating producer acknowledgment settings to failure risk.
How it connects
Connects partition leaders to replicas, in-sync replicas, metadata requests, producer acknowledgments, and consumer reads.

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 Apache Kafka in Action. The section links point to the parts of the book it draws on.