liveBook · Manning

Raft

As explained in Apache Kafka in Action

Raft is a distributed consensus algorithm and protocol for coordinating replicated state machines so cluster nodes agree on replicated state.

Raft is a distributed consensus protocol for coordinating replicated state and reaching agreement across cluster nodes. Kafka uses it through KRaft, replacing ZooKeeper-based coordination with an integrated controller cluster. section 7.1 section 7.5

KRaft reduces operational complexity by removing the need to run Kafka and ZooKeeper as separate distributed systems. Controllers coordinate the cluster while brokers handle normal Kafka workloads. section 7.1 section 7.5

In a KRaft cluster:

  • Controller nodes form the coordination cluster and elect an active controller. section 7.1
  • The active controller monitors brokers, manages partition assignments, and performs leader assignments and failover. section 7.1 section 7.5
  • The __cluster_metadata topic stores consistent metadata across brokers. section 7.5
  • An odd number of controllers supports failure tolerance: one controller suits local development, three tolerate one failure, and five tolerate two. section 7.1

Choosing a controller count

A local Kafka setup can use one controller-broker, but it has no failover guarantee. A production-oriented setup can use three controller-brokers to survive one controller failure; five can survive two. section 7.1

Figure 7.1 With Kafka 3.3, ZooKeeper was replaced by a coordination cluster based on the Raft consensus protocol.
A screenshot of a computer screen

AI-generated content may be incorrect.

Use the architecture figure to see how Kafka's coordination cluster based on Raft replaces ZooKeeper. section 7.1

How Apache Kafka in Action covers it

How deep it goes
Explains KRaft roles, controller quorum sizing, metadata storage, and migration steps without detailing Raft internals.
Examples
Uses one-, three-, and five-controller configurations plus ZooKeeper-to-KRaft metadata migration as operational examples.
What it assumes
Assumes Kafka cluster terminology and distributed-systems context while introducing the controller-broker coordination model.
What you can do after
Operate/configure Kafka KRaft clusters with appropriate controller counts and understand the path from ZooKeeper coordination to KRaft.
How it connects
Connects distributed consensus with Kafka, KRaft, ZooKeeper, controllers, brokers, partition assignments, leader election, and metadata.

Also explained in

Compare how 3 books explain Raft →

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.