---
title: "Remove a Kafka broker safely: drain it first"
description: "Move every partition off broker-4 and let the replacements join the ISR. Removing the empty Kafka broker then causes no ISR shrink and no leader election."
url: https://monedula.dev/kafka-simulator/scenarios/scale-in-drain-broker/
---

# Remove a Kafka broker safely: drain it first

Scenario 07.1.2 · Scale in: drain and remove a broker. Operations · Intermediate · about 3 min · Apache Kafka 4.3.

Reassign a broker’s partitions away first, let the replacements join the ISR, then remove the now-empty broker cleanly.

Run it: https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2

## What you start with

Removing a broker that still hosts replicas is disruptive - every partition it holds drops it from the ISR, and a re-election fires for any it was leading. The safe way to scale in is to DRAIN first: reassign every partition off the broker, let the replacements catch up into the ISR, then remove the now-empty broker. broker-4 hosts replicas on partitions 1 and 2, so we reassign both away before removing it.

## Step by step

1. **Cluster ready** (t+0.000s): Four brokers, RF 3, min.ISR 2. broker-4 is a replica on partitions 1 and 2 (it is the broker we will scale in). [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=0)
2. **Records produced** (t+6.000s): O5 committed to partition 1, O4 to partition 2 (acks=all). High-watermark 1 on both - so a drained replacement will have real data to catch up on. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=1)
3. **Draining partition 1** (t+8.050s): reassign_partition moves partition 1 off broker-4: broker-1 joins at offset 0 and starts fetching, and leader broker-2 is untouched. The simulator drops broker-4 at once; real Kafka keeps it in the replica set and ISR until broker-1 has caught up. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=2)
4. **Partition 1 drained** (t+8.500s): broker-1 caught up to the high-watermark and joined the ISR. Partition 1 no longer references broker-4. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=3)
5. **Draining partition 2** (t+12.050s): reassign_partition moves partition 2 off broker-4: broker-2 joins at offset 0 and fetches. Leader broker-3 stays. broker-4 now hosts no replicas in the simulator; in Kafka it would keep this one until broker-2 joins the ISR. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=4)
6. **Partition 2 drained** (t+12.500s): broker-2 is in the ISR. broker-4 is fully drained - it leads nothing and replicates nothing. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=5)
7. **broker-4 removed** (t+16.050s): remove_broker on the empty broker is a clean no-op: no ISR shrink, no leader election, nothing under-replicated - because the drain already moved every replica away. [Open at this step](https://monedula.dev/kafka-simulator/playground/?scenario=07.1.2&t=6)

## The takeaway

Always drain a broker before removing it: once it holds nothing, remove_broker is a clean no-op - no ISR shrink, no leader election, nothing left under-replicated.

## Configs in this scenario

- [`min.insync.replicas`](https://kafka.apache.org/43/configuration/topic-configs/#topicconfigs_min.insync.replicas): The fewest in-sync replicas, leader included, that must have a write for an acks=all produce to succeed (default 1); with fewer in the ISR the leader rejects the write with NOT_ENOUGH_REPLICAS. [How min.insync.replicas works](https://monedula.dev/kafka-simulator/configs/min-insync-replicas/)
- [`acks`](https://kafka.apache.org/43/configuration/producer-configs/#producerconfigs_acks): How many replicas must have a write before the producer counts it as sent: 0 (none), 1 (the leader only) or all (every in-sync replica, the default, and required for idempotence). [How acks works](https://monedula.dev/kafka-simulator/configs/acks/)

## Further reading

- [Apache Kafka documentation](https://kafka.apache.org/43/operations/basic-kafka-operations/)
