Video in progress
What does moving from ZooKeeper to KRaft give you, and how do you plan the migration?
KRaft stores metadata in Kafka's own Raft quorum: the separate ZooKeeper cluster goes away, controller failover gets faster and the partition limit goes up a lot. In Kafka 4.0 ZooKeeper mode is removed completely, so the migration is mandatory before moving to 4.x.
📖 Answer
In the ZooKeeper era the controller broker read the metadata from ZK and pushed it to the brokers. On a controller change the new controller had to reload everything from ZK, which takes minutes on a big cluster. In KRaft the metadata is the __cluster_metadata log; the controllers replicate it with Raft, and the brokers read it like a consumer. The new controller already has the full state in memory, so failover is nearly instant.
What you gain in practice: running one system (no separate monitoring, security or upgrades for ZK), scaling to millions of partitions, and a simpler security model.
The migration plan (on the last 3.x versions, before 4.0):
- First upgrade the cluster to a 3.x version that supports migration (3.9 is recommended).
- Bring up a separate KRaft controller quorum (3 or 5 nodes), in migration mode.
- Rolling restart the brokers with the migration flag: the metadata is copied from ZK to KRaft, and for a while writes go to both (dual-write).
- Move the brokers fully to KRaft mode, and at the end disconnect the controllers from ZK and shut ZK down.
Until the last step you can roll back; after it, you can't. So I watch for a few days after each stage.
Places to be careful: old tools that connect to ZK directly (scripts with the --zookeeper flag, old monitoring), ACL migration, and library versions. You should compile that list before the migration; that's usually where most of the time goes, not Kafka itself.
Sign up to mark studied questions and save your progress.