Scrivio Interview library
DesignAdvanced7 min read · updated 13 November 2026

You are designing the controller layer for a Kafka 4.x deployment with 60 brokers and about 40,000 partitions across three availability zones.

Decide between combined and dedicated controllers, three or five voters, and their placement, and explain how you would later add or replace a controller.

For 60 brokers and 40,000 partitions I would run dedicated controllers, not combined mode, so broker load cannot slow metadata commits. Five voters placed two, two and one across the three zones survive two failures, which covers a planned restart overlapping an unplanned failure and the loss of a zone; three voters, one per zone, is the leaner choice that survives one failure including a zone loss. I would format the cluster with a dynamic quorum (KIP-853, Kafka 3.9 and later) so controllers can later be added or replaced with kafka-metadata-quorum.sh add-controller and remove-controller.

Why this question is asked

The controller layer is small in machine count but carries the whole cluster's ability to change and to heal. A design mistake here, such as controllers sharing busy disks or an even number of voters, shows up only in a bad week, when it hurts most. Interviewers ask this design question to see whether we can turn quorum arithmetic and failure domains into a concrete layout, size it, and plan its lifecycle. In this answer, we will decide between combined and dedicated controllers, choose three or five voters and place them, size the machines, plan how to add or replace a controller, and decide what to monitor.

1Combined or Dedicated Controllers

In combined mode a node runs process.roles=broker,controller, so the same JVM serves partition traffic and votes on metadata. That saves machines and is perfectly fine for development and for small clusters. At our scale it is a poor trade. A broker with 40,000 / 60, roughly 670, partition leaders and followers does heavy disk and network I/O, may have long garbage collection pauses, and is restarted for every broker upgrade. All of those would delay metadata commits, and a metadata commit is on the path of every leader election.

Dedicated controllers isolate the control plane. They are restarted only when we upgrade them, their disks hold only the metadata log, and their heap holds only the metadata image. The cost is a handful of small virtual machines, which is negligible next to 60 brokers. So the first decision is easy: dedicated controllers.

2Three or Five Voters, and Where They Go

A Raft quorum needs a majority. Three voters tolerate one failure; five tolerate two. With three voters, one per zone, losing an entire zone leaves two of three, so the cluster keeps committing. The weakness appears during maintenance: while one controller is restarting for an upgrade, a second failure anywhere stops the control plane.

Five voters spread two, two and one across zones A, B and C tolerate two failures. Losing zone A takes two voters, leaving three of five, still a majority. And a planned restart of one controller plus an unexpected crash of another still leaves three. The cost is two more small machines and slightly higher commit latency, because the leader waits for two followers instead of one, which is tiny within a region.

For 40,000 partitions serving many teams, I would choose five. If the organisation is cost-sensitive and maintenance windows are well controlled, three is a defensible choice. Four is never the answer: it still tolerates only one failure.

Controller layouts across three zones
LayoutSurvivesDoes not survive
3 voters, 1/1/1any one node or one zonerestart plus one more failure
5 voters, 2/2/1any two nodes, any one zonezone with 2 voters plus one more node
4 voters, 2/1/1one nodeloss of the zone with 2 voters
Combined mode on brokerssame counts as abovebroker load slowing every commit
Five voters placed 2/2/1 is the layout that rides out maintenance and a zone loss together.

3Sizing the Controller Machines

Controllers need little CPU. What they need is low and stable latency. The metadata log is fsynced on every append, so a fast local SSD for the metadata log directory matters more than its size. The network between zones should be low-latency, because each commit is a round trip to the followers.

Memory is driven by the metadata image, which grows with partition count, replicas, configs and ACLs. For 40,000 partitions with replication factor 3 the image is in the order of a few hundred megabytes in memory, so a heap of a few gigabytes gives plenty of headroom; we confirm by measuring heap after startup in a staging cluster of the same size rather than guessing. Snapshots should be on, which they are by default, so a restarting controller loads a snapshot and replays only a short tail instead of the whole log. A restart that takes seconds instead of minutes shortens the window in which we run with reduced tolerance.

4Adding or Replacing a Controller Later

Before Kafka 3.9, voters were a fixed list in controller.quorum.voters on every node. Changing it meant editing every configuration and doing careful rolling restarts in the right order, and a mistake could split or stall the quorum. KIP-853, available since Kafka 3.9, introduced dynamic quorums. Nodes find the quorum through controller.quorum.bootstrap.servers, and voters are added or removed with commands that write the change into the metadata log itself.

To replace a failed controller in zone B, we format a new node as a controller (it gets a new directory id), start it so it joins as an observer and catches up, then add it as a voter, and finally remove the dead voter. Because each step is itself a committed metadata change, the quorum must have a majority while we do it, which is one more reason to prefer five voters.

Java
# format and start the new controller, then let it catch up as an observer
bin/kafka-storage.sh format --cluster-id $CLUSTER_ID --config controller.properties --no-initial-controllers
# promote it to voter (run against the quorum)
bin/kafka-metadata-quorum.sh --command-config controller.properties \
--bootstrap-controller c1:9093 add-controller
# remove the failed voter by its node id and directory id
bin/kafka-metadata-quorum.sh --bootstrap-controller c1:9093 \
remove-controller --controller-id 4 --controller-directory-id <dir-id>
bin/kafka-metadata-quorum.sh --bootstrap-controller c1:9093 describe --status # 5 voters again

Notice the order: catch up first, then add, then remove. Removing first would shrink the quorum while we are already one voter short. The exact flags have changed between releases, so check your version's documentation before running these commands.

5What to Monitor

The single most important signal is ActiveControllerCount summed across all controllers: it must be exactly one. Zero means no leader, and more than one for longer than an election means something is badly wrong. Next comes follower lag in the metadata quorum, from describe --replication or the Raft metrics, because a lagging follower silently reduces our failure tolerance.

We also watch the controller event queue time, which shows when the active controller is overloaded, metadata error counts on brokers and controllers, which show records that failed to apply, and the fenced broker count, which shows brokers that lost their session. Each of these maps to a runbook step, so an alert tells the on-call engineer what to check next.

6Follow-up questions

How would you check whether an existing cluster was formatted with a static or a dynamic quorum?

Look at the kraft.version feature level. A static quorum, configured with controller.quorum.voters, runs kraft.version 0; a dynamic quorum, formatted with --initial-controllers or --standalone and using controller.quorum.bootstrap.servers, runs kraft.version 1. kafka-features.sh describe shows the finalized level, and kafka-metadata-quorum.sh describe --status shows the voters with their directory ids in a dynamic quorum. Check your version, because upgrading an existing static quorum to dynamic became possible only in later releases.

Why not seven voters for even more safety?

Seven voters tolerate three failures, but each commit waits for three followers, the controllers cost more, and with only three zones some zone must hold three voters, so a zone loss plus one node failure already hurts. For a single-region cluster, five is the usual ceiling.

7Conclusion

In this answer, we chose dedicated controllers for a 60-broker, 40,000-partition cluster, picked five voters placed two, two and one across three zones so the quorum survives two failures and any zone loss, and sized them for low disk and network latency with a heap that fits the metadata image. We formatted the quorum as dynamic so controllers can be added and removed with kafka-metadata-quorum.sh, always catching up and adding before removing, and we monitored the active controller count, quorum lag, event queue time, metadata errors and fenced brokers.

What to say in the interviewAbout 90 seconds aloud

Open with

At 60 brokers and 40,000 partitions I would not use combined mode. Brokers at that size do heavy disk and network work and get restarted often, and I do not want that to slow metadata commits, which sit on the path of every leader election.

Then, if they want more

So I would run dedicated controllers. For the count, three voters, one per zone, survive one failure including a full zone loss, but during a planned controller restart a single extra failure would stop the control plane.

Five voters placed two, two and one survive two failures: a maintenance restart plus a crash, or the loss of a zone with two voters, still leaves three of five. I would choose five here, and never an even number, since four adds no tolerance.

The machines need little CPU but fast local disks for the fsynced metadata log, low-latency links between zones, and a heap sized for the metadata image, measured in staging. Snapshots keep restarts fast.

I would format the quorum as dynamic, which is available since Kafka 3.9 through KIP-853, with controller.quorum.bootstrap.servers, so replacing a controller is format the new node, let it catch up as an observer, run add-controller, then remove-controller for the old one.

Finally I would alert on ActiveControllerCount being exactly one, quorum follower lag, event queue time, metadata errors and fenced brokers.

About this answer

Last updated
13 November 2026
Versions it names
Kafka 3.9
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Apache Kafka documentation
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Decide between combined and dedicated controllers, three or five voters, and their...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/d7c2339cf1/