Monedula

Watch a client fail over

Kill a broker on the Kafka Simulator canvas while a real producer and consumer run through monedula-sim-bridge, and watch them move to the new leaders.

How-to guides 4 of 4

2 min read

Updated 26 November 2026

Markdown

On this page

The bridge opens one Kafka listener per simulated broker and closes it when that broker dies. So killing a broker on the canvas does to a real client what a broker crash does: its connections drop, its requests to the dead broker fail with retriable errors, it refreshes its metadata and carries on against the new leaders.

Before you start

Steps

1. Start a producer and a consumer

Keep both running in their own terminals:

bin/kafka-producer-perf-test.sh --topic clicks --num-records 100000 \
  --throughput 20 --record-size 32 \
  --producer-props bootstrap.servers=127.0.0.1:19092
bin/kafka-console-consumer.sh --bootstrap-server 127.0.0.1:19092 \
  --topic clicks --group clicks-readers

--throughput 20 keeps the producer under the playground’s 200 records a second per app, so it is not throttled.

2. Kill a broker

Select broker-1 on the canvas, then kill · hard broker-1. The partitions it led elect new leaders from their in-sync replicas, and the bridge closes the port of broker-1.

Watch the clients:

  • The producer’s requests to the old leader fail with a retriable error, NOT_LEADER_OR_FOLLOWER or a dropped connection, so it fetches new metadata and sends to the new leader. With the default idempotent producer, a batch that was retried is written once.
  • The consumer’s fetches from the old leader fail the same way, and it fetches from the new leader where it left off.

3. When the broker was the group coordinator

The playground picks the coordinator of a group from its group id and the live brokers, so the broker you killed may have coordinated clicks-readers. If it did, the coordinator moves to another live broker, the members get NOT_COORDINATOR, look the coordinator up again and stay in the group. We tested this with the Java consumer: it keeps consuming without losing its group. Kill and restart other brokers one at a time to hit the coordinator if the first was not it.

4. Bring the broker back

Select broker-1, then restart broker-1. Its port opens again, and the clients use it once their next metadata refresh lists it.

Why the client sees real errors

Each simulated broker has its own port: broker 1 on 19092, broker 2 on 19093, and so on. A request reaches the broker the client chose, and the playground answers as that broker would: a broker that does not lead the partition says so, and a dead broker has no port at all. See How it works and Error codes.