Prev Next

Integration / Apache Kafka Interview questions

How do you migrate a Kafka cluster from ZooKeeper mode to KRaft mode?

Since Apache Kafka 4.0 removed ZooKeeper mode entirely, any cluster still running on it must migrate to KRaft before upgrading to 4.0 or later — there is no direct ZooKeeper-to-4.0 upgrade path. The supported migration runs on a 3.x release that still supports both modes, moving the cluster over while it stays online.

  1. Upgrade to a 3.x release that supports migration (Kafka recommends being on a recent 3.x, e.g. 3.9.x, before starting) if not already there.
  2. Deploy a new KRaft controller quorum alongside the existing ZooKeeper ensemble, configured in migration mode rather than replacing anything yet.
  3. Enable migration on the brokers (zookeeper.metadata.migration.enable=true), which starts syncing existing cluster metadata from ZooKeeper into the new KRaft controllers.
  4. Verify the migration has completed and the KRaft controllers hold a full, correct copy of cluster metadata before proceeding further.
  5. Roll the brokers one at a time to run in KRaft mode instead of ZooKeeper mode, removing their ZooKeeper dependency broker by broker.
  6. Decommission the ZooKeeper ensemble once every broker has been confirmed running purely on KRaft.
  7. Only then upgrade to Kafka 4.0+, which requires the cluster to already be fully on KRaft.

The whole process is designed to run without cluster downtime, but it's a multi-step, order-sensitive migration rather than a simple version bump, which is why Kafka's own documentation strongly recommends testing the full sequence against a non-production cluster first.

Can a cluster upgrade directly from ZooKeeper mode straight to Kafka 4.0?
How are brokers moved over during a ZooKeeper-to-KRaft migration?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Robinhood Logo

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

What is a Kafka topic? Mention some of the Apache Kafka terminologies. What is the Global Unique identifier of a Kafka Message? What is a partition in Kafka? What is a Kafka producer? What is Apache Kafka? Explain the role of the ZooKeeper in Kafka. What is a Kafka consumer? What is a consumer group in Kafka? What is Apache ZooKeeper? What is a Kafka broker? Difference between Apache Kafka and Confluent Kafka. Kafka's zero-copy principle. Define replication in Kafka? What is KRaft mode in Kafka? Explain sequential I/O principle in Kafka. What are the types of message delivery semantics in Kafka? What is a Kafka offset used for? List the core APIs provided by Kafka? What is the purpose of a Kafka topic's retention policy? Describe the role of a partition leader in Kafka? What is a Kafka Connect connector? What are Kafka Streams used for? How do you create a topic using the Kafka CLI? What is a serializer in Kafka producer configuration? How do you list existing topics in a Kafka cluster? Why is Kafka better suited than a traditional message queue for high-throughput event streaming? How does Kafka differ from RabbitMQ? What is the difference between at-least-once, at-most-once, and exactly-once delivery semantics? How does Kafka's KRaft controller quorum manage cluster metadata? Why should you configure min.insync.replicas alongside acks=all? How does Kafka handle partition leader election? When should you increase the number of partitions for a topic? What happens when a consumer in a group fails to send a heartbeat in time? Explain the execution flow of a Kafka producer sending a message to a broker? How can you optimize Kafka producer throughput? How do you troubleshoot consumer lag in a Kafka application? Why is the in-sync replica (ISR) set important for durability? Explain the lifecycle of a Kafka consumer group rebalance? How does Kafka achieve exactly-once semantics with idempotent producers and transactions? What is the difference between log compaction and log deletion cleanup policies? How do you implement a custom partitioner in Kafka? How does Kafka Streams manage local state using state stores? Which is better and why: the classic consumer rebalance protocol or the new KIP-848 protocol? How do you integrate a schema registry with Kafka producers and consumers? Explain the internal working of Kafka's replication protocol between leader and follower brokers? How do you configure tiered storage for a Kafka topic? What is the difference between Kafka Connect source and sink connectors? How does Kafka support message compression? When would you choose the cooperative sticky partition assignment strategy? How do you secure a Kafka cluster with SASL and ACLs? Why should unclean leader election be disabled in most production clusters? How do you configure MirrorMaker for cross-cluster replication? Explain the execution flow of a Kafka Streams topology processing a record? How does Kafka report and expose broker and consumer metrics for monitoring? Why doesn't increasing partition count always improve throughput? How do you migrate a Kafka cluster from ZooKeeper mode to KRaft mode? What is the difference between Kafka's Queues feature (KIP-932) and traditional partitioned consumption?
Show more question and Answers...

Akka interview questions

Comments & Discussions