Monedula

Scenario 25.1.6 · HA Schema Registry: the leader fails over

Highly available Schema Registry: leader failover

Schema registry · Advanced · about 4 min · Apache Kafka 4.4 · Confluent Platform feature

Three SR instances, one leader. Kill it and a follower takes over registrations; kill all three and only warm clients keep going.

Run this scenario in the playground

v2 registered through sr-2. t+2.000s

p1 is redeployed with schema v2. Its serializer registers it: the request is forwarded to the leader sr-2, which writes it to _schemas as schema id 2. O2 carries id 2 and the consumer looks it up.

Open at this step: step 4, v2 registered through sr-2

What you start with

Schema Registry runs as a cluster: every instance serves lookups from memory, but only the leader writes new schemas to the _schemas topic. The leader is elected through a Kafka consumer group, among the instances with leader.eligibility=true.

Step by step

  1. three instances · sr-1 leads t+0.000s sr-1, sr-2 and sr-3 joined the schema-registry group on the Kafka cluster; sr-1 won the election and takes registrations. Every instance serves lookups. Open at this step: step 1, three instances · sr-1 leads
  2. O1 written and read t+0.900s Warm clients, no SR calls. Open at this step: step 2, O1 written and read
  3. sr-1 down · sr-2 leads t+1.100s The leader dies and the group elects sr-2. Lookups never stopped: sr-2 and sr-3 hold the whole registry in memory. Open at this step: step 3, sr-1 down · sr-2 leads
  4. v2 registered through sr-2 t+2.000s p1 is redeployed with schema v2. Its serializer registers it: the request is forwarded to the leader sr-2, which writes it to _schemas as schema id 2. O2 carries id 2 and the consumer looks it up. Open at this step: step 4, v2 registered through sr-2
  5. every instance down t+2.300s sr-2 and sr-3 die as well. No leader, no lookups. Open at this step: step 5, every instance down
  6. a cold consumer is stuck t+3.100s c1 restarts with an empty cache and stops at O3: nobody can tell it what schema id 2 is. p1, still warm, keeps writing. Several instances protect against one failure, not against all of them. Open at this step: step 6, a cold consumer is stuck

The takeaway

Several SR instances keep lookups and registrations alive through one failure: followers forward writes, and a follower takes over when the leader goes. They do not help a client that needs SR while all of them are down.

Embed this scenario

Paste this into a blog post, a course page or your team's docs. The scenario plays inside your page, and the link under it points readers to this walkthrough.

<iframe src="https://monedula.dev/kafka-simulator/embed/?scenario=25.1.6" title="Kafka Simulator: HA Schema Registry: the leader fails over" width="100%" height="520" style="border:1px solid #d0d0d0;border-radius:8px" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
<p><a href="https://monedula.dev/kafka-simulator/scenarios/ha-schema-registry/">Highly available Schema Registry: leader failover</a></p>

Further reading

Confluent documentation

Troubleshooting

More in Schema registry

All scenarios