Scenario 25.1.6 · HA Schema Registry: the leader fails over
Highly available Schema Registry: leader failover
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 playgroundthree 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 leadsO1 written and read. t+0.900s
Warm clients, no SR calls.
Open at this step: step 2, O1 written and readsr-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 leadsv2 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-2every 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 downa 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 stuckWhat 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
- 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
- O1 written and read t+0.900s Warm clients, no SR calls. Open at this step: step 2, O1 written and read
- 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
- 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
- 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
- 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
Troubleshooting
More in Schema registry
- Confluent Schema Registry subjects and versions for Kafka
- Kafka schema compatibility: BACKWARD vs FORWARD vs FULL
- Kafka breaking schema change rejected by Schema Registry
- Kafka Schema Registry down: why warm clients keep going
- Kafka Schema Registry down: a restarted client stops
- Schema Registry across two DCs: losing the leader DC
- Schema Registry DR: failover to a follower-only registry
- Two independent Schema Registries break mirrored Kafka data
- Kafka producer schema rejected as incompatible (409)
- Kafka consumer cannot read a new schema under BACKWARD