Skip to the page

Kafka · senior

Kafka 4: KRaft and share groups

Current Kafka runs only in KRaft mode, without ZooKeeper. Share groups add queue-like consumption. Versions change quickly, so check the release notes of your version.

The notes

What you must know

  • ZooKeeper mode was removed in Kafka 4.0. A ZooKeeper cluster must be migrated to KRaft first, using a 3.x release that supports the migration (the last 3.x line is the bridge).
  • KRaft: a quorum of controllers runs Raft over the metadata log. One controller is active and brokers fetch metadata from it. Combined broker-and-controller nodes are for small or test setups.
  • Migration path in outline: upgrade 3.x to the bridge release, add a controller quorum in migration mode, move brokers to KRaft, finalise the migration, upgrade to 4.x, soak, then finalise the metadata version. After finalising you cannot go back.
  • Check before 4.x: client versions (old clients can no longer connect), the Java version needed, removed flags, and tools or monitoring that read ZooKeeper.
  • A consumer group gives each partition to one consumer, so a slow message holds up its partition.
  • Share groups (KIP-932, queues for Kafka): many consumers read the same partitions. Each record is handed out under a time-limited lock and acknowledged one by one (accept, release or reject). Unacknowledged records go back to another consumer. You can have more consumers than partitions.
  • Share groups do not keep order. If order matters, use a consumer group keyed by user.
  • Check your language client and your managed service for share group support before you rely on it.

The red pen

Common traps: mistake → fix

  • Mistake: Kafka still needs ZooKeeper

    Fix: not in 4.x.

  • Mistake: Kafka cannot be a queue

    Fix: share groups give queue-like work sharing on newer versions.

  • Mistake: Share groups keep order

    Fix: they do not.

  • Mistake: Jump straight from 3.6 to the newest version

    Fix: go through the bridge release.

Easy to hard

Questions interviewers ask, easy to hard

  1. How do you move a ZooKeeper Kafka cluster to Kafka 4?
  2. What is KRaft?
  3. What is a share group and when would you use one?
  4. When would you choose SQS or RabbitMQ instead of a share group?

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview