Scrivio Interview library
ScenarioAdvanced6 min read · updated 13 November 2026

A 40-broker cluster grew up in two data halls without broker.rack set and is now moving to three availability zones. Many partitions have two of their three replicas in the same hall.

Plan the change so each partition ends up with one replica per zone without hurting production traffic.

First label every broker with broker.rack in a rolling restart, which changes no assignment by itself. Then generate rack-aware assignments with kafka-reassign-partitions.sh or a balancer such as Cruise Control, review them for leader balance and disk usage, and execute them in small throttled batches, verifying each batch before the next. Place the KRaft controllers so the quorum survives a zone loss, and afterwards enforce placement with replication factor 3 for new topics and an alert for any partition with two replicas in one zone.

Why this question is asked

A cluster that grew without rack labels looks healthy until the day a data hall loses power and partitions with two replicas in that hall go offline or lose their in-sync majority. Fixing placement on a live 40-broker cluster means moving a lot of data, and done carelessly, the fix itself causes the outage. Interviewers ask this scenario to see whether we can plan an operational change in safe, reversible steps. In this answer, we will recap why placement matters, then go through labelling, generating and reviewing the new assignment, executing it with throttles, fixing the controller quorum, and keeping placement correct afterwards.

1A Quick Recap: Why Two Replicas in One Hall Is a Problem

With replication factor 3 and min.insync.replicas=2, a partition accepts acks=all writes as long as two replicas are in sync. If two of its three replicas are in the same hall and that hall fails, only one replica remains: the partition can still elect a leader, but acks=all producers get NotEnoughReplicas errors, and if that last replica was not in sync, the partition goes offline. broker.rack is the setting that tells Kafka which brokers share a failure domain, so it can spread replicas across them. Without it, Kafka placed replicas as if every broker were independent.

2Label the Brokers

We decide which zone each broker belongs to after the move. Brokers that stay in the existing halls get labels for the zones those halls become; new brokers in the third zone start with their label from day one. Then we add broker.rack to every broker's configuration and roll the cluster one broker at a time, waiting for under-replicated partitions to return to zero before the next restart.

Labelling changes nothing about where replicas are. It only gives the assignment tools the information they need. That makes it a safe first step that we can complete and check on its own.

3Generate and Review the New Assignment

Kafka's own tool can generate a rack-aware assignment for a list of topics, but it computes a fresh assignment and can move far more replicas than necessary. A balancer such as Cruise Control, with a rack-awareness goal, computes the smallest set of moves that satisfies placement while also balancing disk, network and leaders. On 40 brokers, that difference can be hundreds of terabytes.

YAML
# Built-in tool: rack-aware by default, but may move many replicas
kafka-reassign-partitions.sh --bootstrap-server b1:9092 \
--topics-to-move-json-file topics-batch-01.json \
--broker-list 1,2,3,...,48 --generate > plan-01.json
# Review the plan before running it
# - every partition: replicas in 3 different racks
# - leaders spread evenly per broker and per zone
# - projected disk usage per broker below 70 percent
# - number of replica moves and bytes to copy

We review each plan as code: a small script checks rack spread, preferred leaders and projected disk per broker. The aim is not only correct placement but a cluster that is still balanced afterwards, because a skewed result creates hot brokers.

4Execute in Small, Throttled Batches

Reassignment copies whole partitions to new replicas, which competes with production traffic for disk and network. We limit it with a replication throttle and move a few hundred gigabytes at a time.

Text
kafka-reassign-partitions.sh --bootstrap-server b1:9092 \
--reassignment-json-file plan-01.json --execute --throttle 104857600
# Successfully started partition reassignments ... (throttle: 100 MB/s)
kafka-reassign-partitions.sh --bootstrap-server b1:9092 \
--reassignment-json-file plan-01.json --verify
# Reassignment of partition orders-3 is completed.
# Clearing broker-level throttles on brokers ...
Step throughOne reassignment batch
  1. Pick the next batch of partitionsMost exposed and most critical first
  2. Generate and review the planRack spread, leaders, disk
  3. Execute with a replication throttleFor example 100 MB/s
  4. Latency and lag within limits?
    YesLet the copy finishNoLower the throttle or pause
  5. Run --verifyConfirms completion, clears throttles
  6. Run preferred leader electionRestore leader balance

6 steps in order. Play them, or step through them one at a time.

We choose the throttle from measured headroom: if producer latency or consumer lag starts to rise, we lower it. Each batch must complete and pass --verify, which also removes the throttle, before the next starts. Running --verify matters; forgetting it leaves throttles in place and slows normal replication later. We work through the most exposed partitions first, those with two replicas in one hall on critical topics, and run the batches during quieter hours.

5Make the Controller Quorum Survive a Zone

Replica placement protects data, but in KRaft mode the cluster also needs a majority of its controller voters to keep metadata moving. With three controllers we run one per zone; with five we use a 2/2/1 layout, so losing any one zone leaves at least three of five voters. Changing voters on a running cluster is supported with dynamic quorums in recent versions (KIP-853, from 3.9); clusters created with a static voter list need more care, so check how yours was set up before planning that step.

6Keep It Correct Afterwards

Placement drifts unless something enforces it. We require replication factor 3 and min.insync.replicas=2 for new topics through the topic creation process, and we run a daily check that reads every partition's replicas, maps brokers to racks, and alerts when any partition has two replicas in the same rack. Manual reassignments and broker replacements go through the same rack-aware tooling. A zone-failure game day in staging, and later in production with care, confirms that the result actually survives.

7Follow-up questions

Why not just add the label and let Kafka fix placement over time?

Because Kafka never moves existing replicas on its own. broker.rack is used only when an assignment is computed, at topic creation, partition addition or a generated reassignment. Without an explicit reassignment, the old placement stays forever.

How long will the move take?

Roughly the bytes to move divided by the throttle, plus review time between batches. If 200 TB must move at 100 MB/s per broker on, say, ten brokers at once, the copying alone is about 2.3 days of continuous transfer, so in practice the plan runs over a few weeks. Using a balancer that minimises moves shortens it the most.

8Conclusion

In this answer, we planned the move to one replica per zone without hurting production: label brokers with broker.rack in a rolling restart, generate rack-aware assignments with the reassignment tool or a balancer that minimises moves, review them for leader and disk balance, execute in small throttled batches with --verify between them, place the controller quorum so it survives a zone loss, and enforce placement afterwards with topic standards and a daily check.

What to say in the interviewAbout 90 seconds aloud

Open with

I would do it in steps that are each safe on their own. First, decide each broker's zone and set broker.rack everywhere with a rolling restart, waiting for under-replicated partitions to clear between brokers.

Then, if they want more

That changes no assignments; it just gives the tools the information. Second, generate rack-aware assignments. Kafka's reassign tool can do it, but it computes a fresh layout and may move far more than needed, so on 40 brokers I would prefer Cruise Control with a rack-awareness goal, which minimises moves and also balances disk and leaders.

Either way I review the plan: three racks per partition, leaders spread evenly, projected disk usage per broker safe. Third, execute in small batches with a replication throttle, starting with the most exposed partitions on critical topics.

I watch producer latency and consumer lag, lower the throttle if they move, and run --verify after each batch, because that confirms completion and clears the throttles. Then a preferred leader election to restore balance.

Fourth, the controllers: one per zone with three voters, or 2/2/1 with five, so the metadata quorum survives a zone loss too, checking whether the quorum is dynamic before changing voters.

Finally, I make it stick: replication factor 3 and min.insync.replicas 2 for new topics, and a daily check that alerts if any partition has two replicas in one rack, then a zone-failure game day.

About this answer

Last updated
13 November 2026
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 "Plan the change so each partition ends up with one replica per zone without hurting...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-internals/45def045a4/