Architecture · Apache Kafka

ZooKeeper is gone: why Kafka 4.x is a migration, not an upgrade

Raffael Hühnerschulte · 6 min read

Kafka is one of the topics teams ask me about most when they request training. Behind almost every request for a cluster that was set up with ZooKeeper, there is now the same question: what happens when we move to 4.x?

Kafka 4.0 removed ZooKeeper completely. Cluster metadata lives in KRaft, Kafka’s own controller quorum, and a 4.x broker cannot run against ZooKeeper at all.

Why a version bump is the most expensive mistake

That is why I think the most expensive mistake is to treat this as a version bump: change the version in the Helm chart, roll the brokers, done. There is no direct jump from a ZooKeeper-based 3.x cluster to 4.x. The migration has a point of no return, and most teams only find out where it is when they need to go back.

PhaseRollback to ZooKeeper possible?ZooKeeper still needed?Upgrade to 4.x allowed?
Migration mode (before finalizing)Yes – how depends on the step you reachedYesNo
After finalizingNoNo – decommission itYes

The KRaft migration order I teach

So this is the order I teach and recommend:

  1. Inventory everything that still talks to ZooKeeper: scripts with --zookeeper flags, monitoring checks, ACL tooling, old clients. Check the 4.0 floor at the same time: brokers need Java 17 (clients and Streams Java 11), and every client, including Streams and Connect, must be on 2.1 or higher before the brokers move to 4.0.
  2. Upgrade the brokers to 3.9.1 with inter.broker.protocol.version=3.9 – the starting point for the migration – while you are still on ZooKeeper.
  3. Start a KRaft controller quorum in migration mode and let it copy the metadata. The controllers use the same cluster ID as the existing cluster, their node.id must not collide with any broker.id, and the metadata version stays untouched for the whole migration.
  4. Move the brokers over one by one and watch them under real load.
  5. Rehearse the rollback before you finalize. Until ZooKeeper is removed for good you can go back; after finalizing you cannot.
  6. Finalize, decommission ZooKeeper, and only then upgrade to 4.x.

The order is boring. Skipping a step is what turns a planned weekend into an incident.

Check the official steps The exact configuration for each phase is in the Apache Kafka documentation: KRaft migration in 3.9 and upgrading to 4.0. Use this article for the order and the decisions, the docs for the flags.

FAQ: moving Kafka from ZooKeeper to KRaft

Can I upgrade from Kafka 3.x with ZooKeeper directly to 4.0?

No. Kafka 4.0 has no ZooKeeper mode. Migrate to KRaft on 3.x first, starting from 3.9.1, and upgrade to 4.0 only after the migration is finalized.

Can I roll back a KRaft migration?

Yes, while the cluster is still in migration mode; how you revert depends on the step you reached. Once the migration is finalized and ZooKeeper is removed, there is no way back.

Which Java version does Kafka 4.0 need?

Brokers, Connect and the tools need Java 17. Clients and Kafka Streams need Java 11. Clients older than version 2.1 are no longer supported, so upgrade them before the brokers.

Should we migrate in place or build a new KRaft cluster?

In place keeps topics, offsets and client connections where they are, but every step happens on the production cluster. A new KRaft cluster makes falling back simple, because the old cluster keeps running, but you have to mirror the data and switch every client over.

Go Deeper

Planning the move off ZooKeeper?

Send me your Kafka version, the number of clusters and your team size – I’ll reply with a training outline or a short migration plan.