Schema Registry High Availability in Kafka

Schema Registry High Availability in Kafka

A plain-English deep dive into how the Kafka Schema Registry stores schemas, elects a primary, serves thousands of clients, and keeps working when servers, zones, or whole data centers fail, with design, operations, and troubleshooting advice for production.

Imagine a busy international airport where every airline, ground crew, and border officer follows one shared phrasebook. A pilot says a code word, and everyone instantly knows what it means because the meaning is written in the phrasebook. Now imagine that the only copy of the phrasebook sits in one office, and that office is locked for a day. Planes that already know their codes keep flying, but the moment a new code appears, or a new crew arrives, work stops. The airport would obviously keep several copies of the phrasebook in several offices, with one person in charge of approving changes so that two people never write conflicting entries.

The Kafka Schema Registry is that phrasebook for your data. Producers and consumers agree on the shape of every message by looking it up in the registry. If the registry is down at the wrong moment, applications can stall, deployments can fail, and new services cannot start. This guide teaches, from zero, how the registry is built, how it stays available, how it can fail, and how to design a setup that survives real-world trouble.

1Why Kafka Data Needs a Schema Registry

Before worrying about availability, understand what the registry does and why so many systems lean on it.

Apache Kafka stores and moves messages, which it calls records. Kafka itself treats the body of a record as a bag of bytes. It does not know or care whether those bytes describe a customer, an order, or a temperature reading. That freedom is powerful, but it creates a problem. The team writing records and the many teams reading them must agree on what the bytes mean. If the writer quietly renames a field or changes a number into text, every reader can break without warning.

A schema is a formal description of the structure of a record: which fields exist, what type each field has, and which fields are optional. Common schema formats include Avro, Protocol Buffers, and JSON Schema. The Schema Registry is a separate service that stores these schemas, gives each one a unique number, and checks new versions against rules to make sure changes do not break existing readers.

Term 1

Schema

A written description of a record’s fields and their types. It is the agreed shape of the data.

Term 2

Subject

A named bucket in the registry that holds the history of versions of one schema, usually tied to a topic.

Term 3

Schema ID

A unique number the registry assigns to each distinct schema. Records carry this small number instead of the whole schema.

Term 4

Compatibility Rule

A policy that decides whether a new schema version is allowed, such as letting old readers still understand new data.

Term 5

Serializer

Client code that turns an object into bytes and stamps the schema ID on the front.

Term 6

Deserializer

Client code that reads the schema ID from the bytes, fetches the schema, and rebuilds the object.

Simple Analogy

Think of a shipping company that labels each parcel with a tiny code instead of writing out the full packing instructions. The code refers to a page in a master catalog. Anyone receiving the parcel looks up the code in the catalog to learn how to unpack it. The catalog is the Schema Registry, and the code is the schema ID.

i
Remember

The registry is not in the path of every single message. It is consulted when a new schema is seen. That one fact explains most of the behavior you will read about in this guide, including why short outages are often survivable and long ones are not.

2What High Availability Really Means Here

High availability is a promise about staying useful during failures. It helps to define exactly which promises matter for a registry.

High availability means that when a component fails, the system as a whole continues to serve its users, ideally without a human doing anything. For the registry, users fall into two groups with different needs. Readers are producers and consumers that look up schemas. Writers are engineers, deployment pipelines, and applications that register new schema versions. Most of the traffic is reading, and writing is rare and bursty.

QuestionWhat It MeansTypical Goal
Read availabilityCan clients still fetch schemas by ID and by subject?Very high, since every application depends on it
Write availabilityCan new schemas still be registered?High, but a short pause is often acceptable
DurabilityCan a registered schema ever be lost?Never lost, since data may already reference it
ConsistencyDoes every schema ID mean the same thing everywhere?Absolute, since a mismatch corrupts data reading
Recovery timeHow fast does service return after a failure?Seconds to minutes for an instance, minutes to hours for a site
Simple Analogy

In a library, borrowing books is frequent and must always work, while adding a brand new book to the catalog happens rarely and can wait a few minutes. But the catalog number of a book must never point to a different book on different days. Availability of lookups, and absolute consistency of numbering, are the two commitments the registry cares about most.

The registry makes a deliberate choice to protect consistency above all. It guarantees that a schema ID is never reused for a different schema, even at the cost of refusing writes when it cannot be sure it is safe. Reads, on the other hand, are designed to be available from many servers at once. This asymmetry, safe writes through one gate and scalable reads through many, is the heart of its high availability design.

!
Common Misconception

High availability does not mean every operation works during every failure. It means the important operations keep working and the rest degrade in a controlled, predictable way. Knowing exactly which operations degrade is what lets you design around them.

3The Architecture: Kafka as the Storage Engine

The registry keeps no database of its own. It uses a Kafka topic as its durable storage.

A Schema Registry server is a small web application. When you register a schema, the server does not write it to a local disk or an external database. Instead, it writes it as a record into a special Kafka topic, commonly named after an underscore and the word schemas. This topic is the single source of truth. Every registry instance reads the topic from the beginning when it starts, builds an in-memory copy of all schemas, and then keeps following the topic to stay current.

flowchart TB
    subgraph K["Kafka Cluster"]
        T["Internal schemas topic: compacted, single partition, replicated"]
    end
    subgraph SR["Schema Registry Instances"]
        P["Primary instance"]
        S1["Secondary instance 1"]
        S2["Secondary instance 2"]
    end
    P -->|"only the primary writes"| T
    T -->|"all instances read and follow"| P
    T -->|"all instances read and follow"| S1
    T -->|"all instances read and follow"| S2
    C1["Producer"] --> S1
    C2["Consumer"] --> S2
    C3["Admin or pipeline"] --> P
        
FIG 1 — Registry instances are stateless caches over one durable Kafka topic

Why a topic makes a good store

Ordered log

The topic has a single partition, so all writes have one strict order. That order is what makes schema IDs and versions consistent across all instances.

Compaction

The topic is configured so that Kafka keeps only the latest record for each key. Old superseded entries are cleaned up, while the current schemas remain forever.

Replication

Kafka copies the topic across several brokers, so the durability of the registry equals the durability of that topic. Losing one broker loses nothing.

Free replay

A new instance needs no data migration. It simply reads the topic and rebuilds its state, which makes adding and replacing instances easy.

Simple Analogy

Picture a courthouse clerk who keeps no private notes. Every decision is written into one official ledger kept in a fireproof vault. Any new clerk starts work by reading the ledger from page one and then follows new entries as they are added. Clerks are replaceable, but the ledger is sacred.

i
Key Insight

Because the registry instances hold no unique data, making the registry highly available splits into two independent tasks: make the Kafka topic durable and available, and run several registry instances so that no single server is a gate.

4Primary and Secondary Roles

A registry cluster has exactly one instance allowed to write at any moment. The rest serve reads and forward writes.

When several registry instances run together, they elect one of themselves as the primary. Older documentation and some setting names call this the leader or the master. The primary is the only instance that writes to the schemas topic. The other instances are secondaries, sometimes called followers. Secondaries serve read requests directly from their in-memory copy. When a secondary receives a write request, such as registering a new schema, it forwards the request to the primary over the network, and returns the answer to the client.

sequenceDiagram
    participant Cl as Client
    participant S as Secondary instance
    participant P as Primary instance
    participant K as Schemas topic
    Cl->>S: Register a new schema
    S->>P: Forward the request
    P->>P: Check compatibility and assign the next ID
    P->>K: Write the schema record
    K-->>P: Acknowledged by replicas
    P->>P: Read back own write to update memory
    P-->>S: Result with the new ID
    S-->>Cl: Result with the new ID
        
FIG 2 — A write received by a secondary is forwarded to the primary
OperationHandled ByDepends On
Fetch a schema by IDAny instanceIts own in-memory copy
List subjects or versionsAny instanceIts own in-memory copy
Check compatibility of a proposed schemaAny instanceIts own in-memory copy
Register a new schemaPrimary only, forwarded if neededPrimary being elected and the topic being writable
Change compatibility settings or modePrimary only, forwarded if neededPrimary being elected and the topic being writable
Delete a subject or versionPrimary only, forwarded if neededPrimary being elected and the topic being writable
Simple Analogy

A dictionary committee has many clerks who can answer any question about existing words, but only the chief editor is allowed to approve and number new entries. If you hand a new word to any clerk, the clerk simply walks it to the chief editor and brings back the answer. If the chief editor is out sick, lookups continue but no new words can be approved until a replacement is chosen.

Why only one writer

Schema IDs must be unique and must grow in a strict order. If two instances could assign IDs at the same time, they might hand out the same number to two different schemas, and data written with that number would become unreadable or, worse, silently misread. A single writer avoids this entire class of problem without needing complicated agreement protocols between instances.

i
Design Consequence

Adding more instances increases read capacity and read availability, but it does not increase write throughput. Writes always funnel through one primary, which is fine because schema registrations are rare compared with lookups.

5How the Primary Is Elected

Electing a primary without any extra software is done by borrowing a feature Kafka already has: consumer group coordination.

Every registry instance is configured with the same group identifier. When instances start, each joins a group through the Kafka cluster’s group coordinator, exactly like ordinary consumers do. Kafka’s group protocol picks one member of the group as the group’s leader and tells everyone who it is. The registry uses that result to decide which instance is the primary. No separate coordination service is needed in modern versions, so one less system has to be kept healthy.

1

Instances start

Each instance connects to Kafka and asks to join the registry group using the shared group identifier.

2

The coordinator selects a group leader

Kafka’s group coordinator picks a member, and each member also announces the network address at which it can be reached.

3

Eligibility is respected

Only instances allowed to be primary can be chosen. Instances marked as not eligible join the group but never become primary.

4

Everyone learns the primary’s address

Secondaries remember where the primary lives so they can forward write requests to it.

5

The primary catches up before accepting writes

A newly elected primary first reads the schemas topic to its end, so its view is complete before it assigns any new ID.

stateDiagram-v2
    [*] --> Joining
    Joining --> Secondary: Group formed and not selected
    Joining --> CatchingUp: Selected as primary
    CatchingUp --> Primary: Caught up with the topic
    Secondary --> CatchingUp: Previous primary lost and this one selected
    Primary --> Joining: Session lost or group rebalanced
    Secondary --> Joining: Session lost or group rebalanced
        
FIG 3 — The life cycle of a registry instance during elections

What happens when the primary dies

If the primary crashes or loses contact with Kafka, the group coordinator notices that its session has expired after a timeout and starts a new round of group formation. A new primary is selected among the eligible survivors. During the gap, which typically lasts for seconds, read requests continue to work on every surviving instance, but write requests fail or wait, because nobody is authorized to write.

!
Common Mistake

Giving different instances different group identifiers by accident. Each instance then forms a group of one and elects itself primary. You end up with several primaries writing to the same topic, which is exactly the situation the design is meant to prevent. All instances of one registry cluster must share the same group identifier.

6Making the Schemas Topic Bulletproof

Since the topic is the only place schemas live, protecting it is the most important availability decision you will make.

Running fifty registry instances would not help if the schemas topic sat on a single broker with one copy. The durability and availability of the registry can never exceed those of its topic. Treat this topic as the crown jewels of your data platform, with settings that are stricter than for ordinary topics.

Setting 1

Replication factor of three

Keep three copies on three different brokers, ideally in three different racks or zones, so a whole zone can fail without losing the topic.

Setting 2

Minimum in-sync replicas of two

Require at least two copies to be up to date before a write is accepted, so an acknowledged schema is always on more than one broker.

Setting 3

Compaction enabled

The topic must be compacted rather than deleted by age. Time-based deletion would eventually erase schemas that data still refers to.

Setting 4

Single partition

One partition gives a total ordering. Adding partitions would break the ordering that unique IDs depend on.

Setting 5

Unclean leader election disabled

Never allow an out-of-date replica to become the topic’s leader, because that could silently drop acknowledged schemas.

Setting 6

Tight access control

Only the registry’s own identity should be allowed to write to the topic. Anyone who can write to it can rewrite your data contracts.

Simple Analogy

A company keeps its original signed contracts in a vault. It makes sure the vault has three separate copies in three different buildings, that a contract is not considered filed until two copies exist, that old contracts are never shredded on a schedule, and that only the legal department has a key. The topic deserves the same treatment.

The registry usually creates the topic itself

On first start, if the topic does not exist, the registry creates it using its own setting for replication factor. Many installations rely on the default, which may be lower than three on development clusters, and then copy that setup to production by accident. Always verify the topic’s actual replication factor and minimum in-sync setting after the first start, and correct them if needed.

!
Dangerous Mistake

Deleting or recreating the schemas topic. Doing so wipes out every registered schema, and while messages remain in your data topics, nobody can decode them. Protect the topic with access rules and never delete it in a cleanup script.

i
Backup Habit

Even with replication, keep an independent backup of the schemas, for example a scheduled export of all subjects and versions to durable storage. Replication protects against machine failure, while backups protect against human error and bad automation.

7What Clients Do When the Registry Is Down

Clients are surprisingly resilient, because they cache aggressively. Understanding the cache tells you what breaks and what does not.

The serializer inside a producer and the deserializer inside a consumer both remember the schemas they have already seen. A producer asks the registry for an ID once per schema and remembers it. A consumer asks the registry for the schema behind an ID once and remembers it. After that, the registry is not touched for that schema. In a stable system where schemas rarely change, the vast majority of messages never trigger a registry call at all.

flowchart TD
    A["Application needs a schema ID or schema"] --> B{"Already in the local cache?"}
    B -->|"Yes"| C["Use it immediately, no network call"]
    B -->|"No"| D["Call the registry"]
    D --> E{"Registry reachable?"}
    E -->|"Yes"| F["Store in cache and continue"]
    E -->|"No"| G["Retry, then fail the operation"]
        
FIG 4 — The client cache decides whether an outage is even noticed
Scenario During a Registry OutageResultWhy
Long-running producer sending known schemasKeeps workingIDs are already cached
Long-running consumer reading known schema IDsKeeps workingSchemas are already cached
New producer instance startingMay fail on first messageCache is empty and needs an ID lookup
New consumer instance startingFails when it meets an ID it has not seenNeeds to fetch the schema
Producer registering a brand new schema versionFailsRegistration needs the primary and the topic
Consumer group rebalancing onto a new instanceNew instance may stallCold cache
Deployment pipeline checking compatibilityFails the pipelineCannot reach any instance
Simple Analogy

Experienced waiters memorize the menu after a few weeks. If the printed menu shop closes for a day, they carry on serving without trouble. But a brand new waiter starting that day has no memory of the menu, and a new dish added today cannot be described to customers. Warm caches survive, cold ones do not.

The dangerous moments

The risky times are those when many caches go cold together. A mass restart of consumers, a large deployment, an autoscaling burst, or a cluster-wide rebalance can suddenly send thousands of new instances to the registry at once. If the registry is unavailable or slow at that moment, a stable system turns into a stalled one. Registry availability therefore matters most during change, not during calm.

!
Common Mistake

Relying on warm caches as an excuse to skimp on registry availability. It works for months until the day a routine deployment restarts everything while the registry is degraded, and the platform grinds to a halt.

8Client-Side Failover and Load Balancing

Clients need a way to find a healthy instance. There are two common approaches, and many teams combine them.

The client setting that names the registry accepts a list of addresses separated by commas. When one address fails, the client tries the next. This is simple and needs no extra infrastructure. The alternative is to put a load balancer or a DNS name in front of all instances and give clients that single address. The load balancer checks the health of each instance and sends traffic only to healthy ones.

Option 1

Client-side list of addresses

Every client knows every instance. Simple and fast to fail over, but changing the list means reconfiguring clients.

Option 2

Load balancer in front

Clients see one stable address. The balancer hides instance changes and performs health checks, but becomes another component to keep highly available.

Option 3

DNS round robin

A name resolves to several addresses. Cheap, but failover speed depends on DNS caching, which can be slow and uneven.

Option 4

Service mesh or platform service

On container platforms, an internal service address and readiness checks provide balancing automatically.

flowchart LR
    C1["Clients"] --> LB["Load balancer or service address"]
    LB -->|"health checked"| I1["Instance 1"]
    LB -->|"health checked"| I2["Instance 2"]
    LB -->|"health checked"| I3["Instance 3"]
    I1 --> T["Schemas topic in Kafka"]
    I2 --> T
    I3 --> T
        
FIG 5 — A balancer hides individual instances from clients

What a good health check looks like

The registry exposes a simple web address that returns a success answer when the instance is running and able to serve. A good health check calls that address frequently and removes the instance from rotation after a few consecutive failures. It should also consider an instance unhealthy while it is still reading the schemas topic on startup, because serving reads from an incomplete copy would return misleading not-found errors.

Sticky or not

Balancers need not stick a client to one instance. Any instance can answer any read, and writes are forwarded internally. Simple round robin or least connections is enough. One exception is worth noting: because instances catch up with the topic independently, two instances can differ by a tiny moment in what they know, which the next chapter explains.

i
Practical Rule

If you use a balancer, run at least two balancer nodes or use a managed one that is already redundant. A single balancer in front of three registry instances only moves the single point of failure.

9Consistency: Eventually Caught Up

Because secondaries follow the topic, they can lag the primary by a few moments. That is usually harmless, but it explains some puzzling errors.

When the primary registers a schema, it writes to the topic and then reads its own write back before answering. Secondaries also read that record from the topic, but they do it independently and slightly later. For a brief window, perhaps tens or hundreds of milliseconds under normal conditions, a secondary does not yet know about the new schema. If a client asks that secondary for the new ID in that window, it may receive a not-found answer.

sequenceDiagram
    participant Pr as Producer
    participant P as Primary
    participant K as Schemas topic
    participant S as Secondary
    participant Co as Consumer
    Pr->>P: Register new schema
    P->>K: Write record
    P-->>Pr: New ID returned
    Pr->>Pr: Sends data using the new ID
    Co->>S: Ask for schema by the new ID
    S-->>Co: Not found yet, still catching up
    K-->>S: Record arrives shortly after
    Co->>S: Retry the lookup
    S-->>Co: Schema returned
        
FIG 6 — A short window in which a secondary has not yet seen a new schema
Simple Analogy

Branch offices receive the head office’s catalog updates by courier, each at its own pace. If a customer at one branch asks about an item added minutes ago, that branch may not have the page yet. A moment later the courier arrives and the same question is answered. Nothing was wrong, the update was simply still in transit.

Why this rarely hurts

In most systems, the time between a producer registering a schema and a consumer reading a message that uses it is much longer than the lag between instances. Messages first have to be written to Kafka, replicated, and then fetched by the consumer. The consumer’s lookup almost always happens after all instances have caught up. Occasional transient not-found errors are more likely under heavy load or when an instance is recovering.

Safe pattern

Consumers retry a failed schema lookup briefly before giving up. A short retry with a small delay resolves nearly all transient cases.

Risky pattern

Pipelines that register a schema and immediately query a different instance for it, in the same script. Direct such checks at the same instance, or wait and retry.

Recovering instances

An instance that has just restarted may serve incomplete data until it finishes reading the topic. Health checks should keep it out of rotation until then.

i
Insight

Schema IDs never change meaning, so a lagging instance can only say not found, never give a wrong answer. That property is why eventual consistency is acceptable here: the worst case is a retry, not corruption.

10Sizing and Placing Instances

The registry is light on resources. The main design questions are how many instances, and where to put them.

A registry instance is a small web service that holds all schemas in memory and answers mostly simple lookups. Even large organizations with thousands of schemas run it comfortably on modest machines. The bigger risk is not capacity but placement: running all instances on the same machine, the same rack, or the same zone.

Number of InstancesBehaviorAssessment
OneEvery failure or restart is an outageAcceptable only for development
TwoSurvives one failure, but zero spare during maintenanceMinimum for production
ThreeSurvives one failure with a spare, and allows rolling maintenance safelyRecommended standard
Five or moreMore read capacity and resilienceOnly for very high lookup volumes or large regional spread
Placement 1

Different machines

Never run two instances on the same host, since one host failure would remove both.

Placement 2

Different zones

Spread instances across availability zones so a zone outage leaves at least one instance running.

Placement 3

Separate from Kafka brokers

Avoid sharing machines with brokers, so a busy broker does not starve the registry, and a registry problem does not affect the broker.

Placement 4

Close to the clients

Nearby instances reduce lookup latency and cross-zone traffic costs for busy clients.

Simple Analogy

Three fire stations in three different neighborhoods protect a city better than three engines parked in one garage. The trucks are the same, but a single flood or blocked road does not disable all of them.

!
Common Mistake

Running two instances and considering the job done. When one is taken down for an upgrade, the remaining single instance is again a single point of failure, at exactly the moment you are changing things and most likely to have trouble. Three is the practical minimum for calm operations.

11Network Reachability Between Instances

A subtle requirement causes many real incidents: every instance must be able to reach the primary directly.

When a secondary forwards a write, it connects to the primary using the address the primary announced when it joined the group. That address comes from each instance’s own configuration for its advertised host name and listener. If the address is wrong, unreachable from other instances, or resolves to a private address that others cannot use, then forwarding fails, even though every instance can reach Kafka perfectly well.

1

The primary announces its address

During group formation each instance publishes the host name and port it believes it can be reached at.

2

Secondaries remember it

They store the primary’s announced address to use for forwarding.

3

A write arrives at a secondary

The secondary opens a connection to the announced address and passes the request along.

4

Failure if the address is wrong

The connection fails or times out, and the client sees an error saying the request could not be forwarded to the primary.

Container and platform environments

An instance may announce a container-internal name that other containers cannot resolve. Use stable, cluster-resolvable names per instance, and confirm that instances can call each other’s web address.

Load balancer confusion

Announcing the load balancer’s address as the instance address makes forwarding go back out through the balancer, which may send the forwarded write to another secondary, causing loops or errors. Each instance should announce its own direct address.

Encrypted internal traffic

When instances talk to each other over secured connections, the protocol setting for instance-to-instance communication and the trust configuration must match on all instances, or forwarding will fail with handshake errors.

!
Sneaky Failure

This problem often stays hidden for weeks. Reads work everywhere, and writes work whenever the client happens to hit the primary directly. Only when a write lands on a secondary does the misconfiguration show itself, making the failures look random.

12Startup, Restarts, and Rolling Upgrades

Planned changes are the most common cause of registry trouble. A careful procedure removes almost all of it.

On startup an instance must read the entire schemas topic to build its in-memory copy. For a registry with a modest number of schemas this takes seconds. For very large registries, with hundreds of thousands of records, it can take longer, and the instance has a configurable time limit for this initial reading. If Kafka is slow or unreachable, the instance may fail to start within the limit and exit.

1

Verify the cluster is healthy

Confirm all instances are up, the schemas topic is fully in sync, and no partitions are under-replicated.

2

Take one instance out of rotation

Remove it from the balancer and let in-flight requests finish.

3

Stop, upgrade, and start it

The instance leaves the group, and if it was primary a new election occurs within seconds.

4

Wait until it has caught up and is healthy

Only after it has fully read the topic and passes health checks should it return to rotation.

5

Repeat one at a time

Never take down two instances together. Many teams upgrade secondaries first and the primary last to limit the number of elections.

ChangeImpact on ReadsImpact on Writes
Restart a secondaryNone if others remain healthyNone
Restart the primaryNone if others remain healthyPause for the length of the election
Restart all instances at onceOutage until the first is readyOutage until a primary is elected
Kafka broker rolling restartUsually noneBrief hiccup as topic leaders move
i
Platform Tip

On container platforms, use readiness checks that only succeed after the instance has caught up, and a disruption budget that never allows more than one instance to be unavailable at a time. These two settings alone prevent most upgrade accidents.

!
Version Care

Read the release notes before upgrading, especially across major versions. Changes in how records are stored can affect whether older and newer instances can safely share one topic during a rolling upgrade.

13Multi-Zone and Multi-Data-Center Designs

One cluster spread across zones handles most failures. Surviving the loss of an entire region needs a bigger design.

Inside one region, the standard design places three registry instances in three zones, backed by a Kafka cluster that also spans those zones. This survives any single instance, machine, or zone failure with no manual action. Surviving the loss of a whole region requires a second Kafka cluster and a second set of registry instances in another region, with schemas copied between them.

flowchart LR
    subgraph RA["Region A: active"]
        KA["Kafka cluster A"]
        RA1["Registry instances, eligible to be primary"]
        RA1 --> KA
    end
    subgraph RB["Region B: standby"]
        KB["Kafka cluster B"]
        RB1["Registry instances, not eligible to be primary"]
        RB1 --> KB
    end
    KA -->|"schemas replicated continuously"| KB
    AppsA["Applications in Region A"] --> RA1
    AppsB["Applications in Region B"] --> RB1
        
FIG 7 — An active region and a standby region, with schemas flowing one way
Design 1

Single cluster across zones

Simplest and the right answer for most teams. Protects against zone loss but not regional loss.

Design 2

Active and passive regions

Only one region writes. The other holds a continuously updated copy and serves reads locally. Failover is a deliberate switch.

Design 3

One registry stretched across regions

Instances in several regions share one topic in one stretched Kafka cluster. Elegant on paper, but slow links and higher failure chances make it risky unless latency is very low.

Design 4

Schema linking between registries

Some distributions can continuously copy schemas from one registry to another, keeping the same IDs, without you having to replicate the internal topic by hand.

The eligibility setting

Each instance has a setting that says whether it may become primary. In a standby region, you set instances as not eligible, so they can never accidentally elect a local primary and start writing to their copy of the topic. They still serve reads to local applications. During failover, an operator flips the standby to eligible and points writers at it.

Simple Analogy

A company keeps a fully stocked backup office in another city. Staff there can answer questions using the shared files, but only the main office may issue new official documents. If the main office burns down, management formally hands the stamp to the backup office. Doing this deliberately avoids two offices issuing conflicting documents.

!
Split-Brain Danger

Two regions both believing they are active and both registering schemas will assign the same IDs to different schemas. When the copies are later merged, data can be permanently misread. Always ensure only one region is writable at any time.

14Disaster Recovery: RPO, RTO, and the Failover Plan

Two numbers define a disaster recovery plan: how much you can afford to lose, and how long you can afford to be down.

Recovery point objective, shortened to RPO, is the maximum amount of recent data you are willing to lose. Recovery time objective, shortened to RTO, is the maximum time you are willing to be without service. For schemas, the RPO question is: if the active region disappears at this instant, which recently registered schemas might not yet have reached the standby? The RTO question is: how long does it take to turn the standby into the active one?

ApproachTypical RPOTypical RTONotes
Periodic export to storageMinutes to hours, depending on scheduleLong, needs a rebuild and reloadCheap safety net, good as the last line of defense
Continuous replication of the schemas topicSecondsMinutesStandard choice for standby regions
Schema linking between registriesSecondsMinutesSimpler to operate where supported
Stretched clusterNear zeroSecondsNeeds very fast links between sites
1

Decide to fail over

A human or well-tested automation confirms that the active region is truly unavailable, not just slow.

2

Fence the old active region

Make sure the old region cannot accept writes if it returns, for example by blocking its writers or keeping its instances stopped.

3

Verify the standby’s copy

Check that the standby holds the schemas you expect, including the latest IDs, before promoting it.

4

Promote the standby

Allow its instances to become primary and switch it to accept writes.

5

Redirect clients

Point writers, and any clients that used the old region, to the new active address using DNS or configuration.

6

Plan the failback

When the old region returns, rebuild it as the new standby by resynchronizing from the current active, instead of letting it resume its old state.

i
Key Rule

The most important rule of registry disaster recovery is to preserve schema IDs exactly. Data already in Kafka refers to those numbers. A restored registry that assigns different IDs to the same schemas would make old data undecodable.

!
Untested Plans

A failover plan that has never been rehearsed is a wish. Practice the full sequence in a non-production environment, including the failback, and time it. Real incidents are the worst time to discover a missing step.

15Import Mode, Read-Only Mode, and Safe Migrations

The registry has operating modes that make copying and freezing schemas safe.

A registry can run in different modes, applied globally or per subject. In the normal read-write mode, clients can register and read schemas. In read-only mode, registrations and changes are refused while reads continue, which is useful during maintenance or in standby copies. In import mode, the registry accepts schemas together with their existing IDs instead of assigning new ones, which is what makes it possible to copy schemas between registries while preserving their numbers.

Mode 1

Read-write

The everyday mode. Clients read schemas and register new ones, and the primary assigns IDs.

Mode 2

Read-only

Writes are refused. A safe way to freeze a registry during a migration, an audit, or on a standby copy.

Mode 3

Import

The registry accepts schemas with the IDs they already have. Used to load schemas from another registry, and typically only allowed on an empty subject or registry.

Use

Switching with care

Modes are changed through the registry’s own interface, and the change is itself stored in the topic, so all instances see it.

Migrating to a new registry

Put the new registry into import mode, copy every subject and version with their original IDs, verify the counts and IDs, then switch to read-write and move clients over.

Freezing during risky work

Before a Kafka cluster maintenance or a disaster drill, switch to read-only so that nobody can register schemas at an unsafe time.

Keeping a standby honest

Keep the standby registry read-only or import-only so that it only ever receives schemas from the active side and never invents its own.

!
Forgotten Mode

Leaving a registry in read-only mode after maintenance, so that deployments start failing with confusing refusals. Add the mode to your post-maintenance checklist and to your monitoring.

16Running on Kubernetes and in the Cloud

Container platforms make it easy to run several instances, and equally easy to run them badly.

Layer 1

Replicas of at least three

Run three replicas of the registry workload so that upgrades and node failures never leave a single instance.

Layer 2

Zone spreading rules

Use anti-affinity or topology spread rules so replicas land in different zones and on different nodes.

Layer 3

Readiness and liveness checks

Readiness should pass only when the instance has caught up with the topic. Liveness should be lenient enough to avoid killing an instance that is merely catching up.

Layer 4

Disruption budget

A budget that allows at most one replica to be voluntarily unavailable at a time protects against overly aggressive node draining.

Layer 5

Stable instance addressing

Each replica must announce an address that other replicas can reach directly, since forwarding depends on it.

Layer 6

Resource requests and limits

Give enough memory to hold all schemas with headroom, and avoid limits so tight that garbage collection pauses look like failures.

Managed services

Many cloud providers and Kafka vendors offer a managed registry that handles instance counts, placement, upgrades, and storage for you. This removes most of the operational work described in this guide, but you still own client configuration, schema governance, access control, and your own disaster recovery expectations. Check the provider’s availability promise and how failover works, and confirm that the schema IDs are stable across provider-side maintenance.

Simple Analogy

Using a container platform is like hiring a facilities manager who can instantly open three offices. That is powerful, but if you forget to say the offices must be in different buildings, the manager may put all three on the same floor. The tools are only as safe as the rules you give them.

!
Common Mistake

Using an overly strict liveness check that restarts an instance while it is still reading the schemas topic. The instance restarts, starts reading again, gets killed again, and never becomes healthy. Give startup enough time before liveness checks begin.

17Security That Does Not Undermine Availability

Security settings interact with availability more than people expect. A locked door that no one can open is also an outage.

Layer 1

Encrypted client traffic

Serve the registry over encrypted connections and manage certificates with automated renewal. An expired certificate is one of the most common causes of sudden registry outages.

Layer 2

Client authentication

Require clients to identify themselves using credentials or certificates, so that only approved applications can read or register schemas.

Layer 3

Authorization by subject

Limit who may register or delete under each subject. Write access should be given only to the teams that own the schemas, while read access can be broad.

Layer 4

Secure access to Kafka

The registry authenticates to Kafka with its own identity, which needs permission to read and write the schemas topic and to join its group.

Layer 5

Instance-to-instance security

Forwarding between instances must be secured consistently, or it becomes both a weak spot and a failure point.

Layer 6

Deletion controls

Restrict deletion of subjects and versions tightly. Permanent deletion of a schema that data still uses is effectively data loss.

i
Availability Tip

Monitor certificate expiry dates and credential rotation dates as carefully as you monitor servers. Many registry outages are not crashes at all, but a certificate that quietly expired at midnight.

!
Common Mistake

Rotating the registry’s Kafka credentials without updating the access rules for the schemas topic and the registry’s group. The instance keeps running with cached connections, then fails to rejoin the group at the next restart, turning a quiet change into a delayed outage.

18Monitoring, Logging, and Alerting

You cannot keep something available if you cannot see it becoming unavailable.

Metric

Instance up and healthy

Check every instance’s health address from outside, not only from inside its own machine.

Metric

Exactly one primary

Each instance can report whether it is primary. The count across the cluster should always be exactly one. Zero means writes are blocked, and two means a serious configuration problem.

Metric

Request rate and latency

Watch lookup and registration rates and their slow percentiles. A growing latency trend often appears before an outage.

Metric

Error rates by type

Distinguish client errors, such as incompatible schemas, from server errors, such as forwarding failures or storage errors.

Metric

Registered schema counts

The number of subjects and schemas should be equal across instances after catch-up. A persistent difference indicates an instance that is stuck.

Kafka

Schemas topic health

Monitor under-replicated partitions and in-sync replica counts for the topic specifically. It is small, but critical.

Log

Election and group events

Frequent group rebalances point to unstable networks, tight timeouts, or overloaded instances.

External

Certificate and credential expiry

Alert weeks ahead. These are silent time bombs.

An alerting ladder

1

Information

Report daily on instance counts, schema counts, and topic replication settings, to catch drift.

2

Warning

Notify the team when an instance is down, latency is rising, or the primary changes unexpectedly more than once in a short period.

3

Critical

Page an engineer when no instance is healthy, when no primary exists for longer than a few minutes, or when more than one primary is reported.

i
Synthetic Check

Run a small automated test every minute that fetches a known schema and, less often, registers and removes a throwaway test schema. It proves the whole path works, including forwarding to the primary, in the same way real users would use it.

19Design Patterns That Work

These arrangements have been proven again and again in production.

Pattern 1

Three instances in three zones

The default design. Survives an instance, a machine, or a zone failure without action, and allows calm rolling upgrades.

Pattern 2

Hardened schemas topic

Replication factor three, minimum in-sync of two, compaction, single partition, and tightly restricted write access.

Pattern 3

Redundant entry point

A redundant load balancer or platform service, with health checks that understand catch-up state.

Pattern 4

Client-side failover list

Give clients several addresses so that even a load balancer problem does not fully stop them.

Pattern 5

Schemas as code

Keep schemas in version control and register them through reviewed pipelines, not by hand and not at application runtime in production.

Pattern 6

Disable auto-registration in production

Prevent applications from creating schemas on the fly, so registrations happen only through controlled pipelines and never during peak traffic.

Pattern 7

Standby region with fenced writes

A read-only or non-eligible standby that receives schemas continuously and is promoted only through a rehearsed procedure.

Pattern 8

Independent backups

Scheduled exports of every subject and version to storage outside Kafka, protecting against human error.

Simple Analogy

Good patterns are like the safety habits of an experienced pilot: check the aircraft in a fixed order, have a second pair of instruments, brief the crew before takeoff, and rehearse emergencies. None of it is exciting, and all of it is why flights are uneventful.

“A schema registry is only as available as the Kafka topic beneath it and the discipline around it.”

20Anti-Patterns to Avoid

These mistakes appear in real incidents. Learn them so you do not repeat them.

ANTI-PATTERN-01 Avoid
Problem

A single registry instance serves the whole platform.

Why It’s Harmful

Every restart, patch, or crash stops schema lookups for new clients and blocks all registrations. Mass restarts elsewhere turn this into a platform-wide stall.

Correct Approach

Run at least three instances across zones behind a redundant entry point.

ANTI-PATTERN-02 Avoid
Problem

The schemas topic has a replication factor of one or a low minimum in-sync setting because the registry created it with defaults.

Why It’s Harmful

Losing one broker can lose every schema, or make the registry unwritable. The many instances in front provide no protection against this.

Correct Approach

Verify and correct the topic’s replication factor and minimum in-sync setting right after the first start.

ANTI-PATTERN-03 Avoid
Problem

Instances are configured with different group identifiers, or two separate registries share one schemas topic.

Why It’s Harmful

Multiple primaries can write concurrently, causing duplicate IDs and corrupted contracts.

Correct Approach

One group identifier per registry cluster, and exactly one registry cluster per schemas topic.

ANTI-PATTERN-04 Avoid
Problem

Applications register schemas automatically at runtime in production.

Why It’s Harmful

A bug or a mass deployment can create bursts of registrations, all funneled to one primary, and can introduce unreviewed schema changes at the worst moment.

Correct Approach

Turn off auto-registration in production and register schemas through a controlled, reviewed pipeline before deploying applications.

ANTI-PATTERN-05 Avoid
Problem

The standby region is writable and eligible to elect its own primary, while the active region is also running.

Why It’s Harmful

Two independent primaries assign the same IDs to different schemas. Data written by both regions cannot be reconciled safely.

Correct Approach

Mark standby instances as not eligible, keep the standby read-only, and promote through a fenced procedure only.

ANTI-PATTERN-06 Avoid
Problem

All instances are restarted together for an upgrade or a configuration change.

Why It’s Harmful

The registry is unavailable for the full startup time plus election time, and every new client in that window fails.

Correct Approach

Roll one instance at a time, waiting for each to catch up and pass health checks before moving on.

ANTI-PATTERN-07 Avoid
Problem

Schemas are deleted or the schemas topic is recreated during cleanup of a test environment, using the same scripts as production.

Why It’s Harmful

Data already in Kafka becomes undecodable. Recovery depends entirely on having a backup.

Correct Approach

Separate test and production tooling, restrict deletion rights, and keep independent backups.

21Troubleshooting Common Failures

Most registry incidents fall into a few families. Recognize the family and the fix is usually short.

SymptomLikely CauseWhat to Check
Registrations fail, lookups workNo primary elected, or forwarding to the primary failsPrimary indicator on each instance, group events, instance-to-instance reachability
Error saying the request could not be forwarded to the primaryAnnounced address unreachable or wrong protocolAdvertised host name, listener settings, network rules between instances
Random write failures that work on retryOnly some instances misconfigured, or a primary that is repeatedly changingConfiguration diff between instances and group rebalance frequency
Instance never becomes healthy after startCannot read the schemas topic, or startup timeout too short, or liveness check killing itBroker connectivity, topic permissions, startup time limit, probe timing
Schema not found right after registrationReading from an instance that has not caught upRetry after a short delay, and compare schema counts between instances
Different instances return different schema countsOne instance is stuck or lagging on the topicThat instance’s logs and its consumer position on the topic
Everything fails after a security changeExpired certificate or changed credentials or access rulesCertificate dates, credential validity, access rules for the topic and group
Two instances both report being primaryDifferent group identifiers or separate group coordinationGroup identifier setting and topic settings on all instances
All writes refused with a mode errorRegistry left in read-only modeGlobal and per-subject mode settings

A calm debugging routine

1

Separate reads from writes

Test a simple lookup and then a registration against each instance directly, bypassing the balancer.

2

Find the primary

Determine which instance thinks it is primary and whether that is unique across the cluster.

3

Check the underlying topic

Confirm that the schemas topic is healthy, fully replicated, and writable.

4

Test instance-to-instance connectivity

From each secondary, verify that the primary’s announced address is reachable using the expected protocol.

5

Review recent changes

Look for upgrades, certificate rotations, network rule changes, or credential updates that line up with the start of the problem.

i
Debugging Tip

Ask three separate questions: can clients read, can clients write, and is the storage healthy. Each has different causes, and answering them in order keeps you from chasing the wrong problem.

22Real-World and Industry Scenarios

The same design plays out differently depending on the business.

Banking and payments

Schemas describe payment events shared by dozens of teams. Three instances across zones, a hardened topic, a rehearsed standby region, and strict control over who can register or delete schemas satisfy both operational and audit needs.

Retail and e-commerce

During a big sale, autoscaling launches many new consumer instances at once. Registry capacity and warm-up behavior matter more than raw schema volume, because a burst of cold caches hits the registry all at the same moment.

Streaming media and analytics

Hundreds of pipelines read shared event streams. Registry availability is a shared dependency, so a standard client failover list and a lookup-friendly entry point keep any single instance issue invisible to them.

Healthcare

Data contracts must be auditable and never lost. Independent backups, strict deletion controls, and regional placement inside legal boundaries are the main design drivers.

Telecommunications and IoT

Very large fleets of gateways and devices connect and reconnect constantly. Stable schema IDs and warm client caches keep the registry load low, while a standby region protects against loss of a site.

Multi-tenant data platforms

A central team runs one registry for many internal customers. Subject naming rules, per-team authorization, and central control over registration keep the shared contract store safe and understandable.

Three instances
across three zones
Three copies
of the schemas topic
One primary
writing at any moment
i
Industry Lesson

Every mature platform ends up with the same three habits: harden the storage topic, run enough instances in separate failure domains, and keep schema changes flowing through controlled, reviewed pipelines.

23Best Practices and Common Mistakes

A compact checklist you can use before, during, and after rollout.

Best Practices

  • Run at least three instances across separate zones and machines
  • Give every instance of one registry cluster the same group identifier
  • Harden the schemas topic with replication factor three and minimum in-sync of two
  • Verify the topic’s settings after the first start, not just the registry’s
  • Announce reachable, per-instance addresses for forwarding
  • Use health checks that understand catch-up state
  • Roll upgrades one instance at a time
  • Disable auto-registration in production and register through pipelines
  • Keep independent backups and rehearse the failover and failback

Common Mistakes

  • Trusting default topic settings on the first start
  • Running two instances and calling it highly available
  • Giving instances different group identifiers
  • Announcing a load balancer or unreachable name as the instance address
  • Restarting every instance at the same time
  • Leaving a standby region eligible to elect a primary
  • Letting certificates expire unnoticed
  • Forgetting that new clients have cold caches at the worst moments

A short readiness checklist

1

Harden the storage

Confirm replication, minimum in-sync, compaction, single partition, and access rules on the schemas topic.

2

Deploy the instances

Three or more instances in separate zones, identical group identifier, reachable announced addresses.

3

Front them properly

A redundant entry point with correct health checks, and a failover list configured in clients.

4

Secure and monitor

Encryption, authentication, per-subject authorization, and alerts for health, primary count, and expiring certificates.

5

Protect against disaster

Set up a standby region or an equivalent recovery path, plus scheduled backups.

6

Rehearse

Kill the primary, kill a zone, and practice the regional failover and failback in a non-production setting.

i
Game Day

Schedule a regular exercise where you stop the primary instance during normal traffic and watch what clients experience. It builds confidence, reveals hidden misconfigurations, and turns theory into practiced skill.

24Frequently Asked Questions

Short answers to the questions people ask most often when they start planning registry availability.

Q1Where does the Schema Registry actually store its data?

In a special Kafka topic. The registry instances keep an in-memory copy built from that topic, so the topic is the only durable store and its safety decides the registry’s safety.

Q2Do all instances accept writes?

No. Only the elected primary writes to the topic. Secondaries accept write requests but forward them to the primary, and they answer read requests themselves.

Q3How is the primary chosen?

Instances join a group through Kafka’s group coordination, and the result of the group’s leader selection decides the primary. Instances marked as not eligible are never chosen.

Q4What happens to my applications if the registry goes down?

Running producers and consumers with warm caches keep working for schemas they already know. New instances, new schemas, and anything that needs registration or a first lookup will fail until the registry returns.

Q5How many instances should I run?

Three is the practical standard, in three zones. Two survive a failure but leave no spare during maintenance, and one is only suitable for development.

Q6Does adding instances make registrations faster?

No. Writes always go through the single primary. More instances add read capacity and resilience, which is where most of the traffic is.

Q7Why did I get schema not found right after registering?

The instance you asked may not yet have read the new record from the topic. Retrying after a short delay normally succeeds, and the answer is never wrong, only briefly missing.

Q8Do I need a load balancer?

Not strictly. Clients can be given a list of addresses and will try the next when one fails. A balancer adds convenience and health checks, but must itself be redundant.

Q9Can I run the registry across two regions for disaster recovery?

Yes, usually as an active region and a standby region with schemas continuously copied. Standby instances should not be eligible to become primary, and promotion should be a controlled, rehearsed action.

Q10What is the most important thing to protect?

The schemas topic and the stability of schema IDs. Lose the topic, or change what an ID means, and data already in Kafka may become unreadable.

Q11Should applications register schemas automatically in production?

It is safer not to. Register schemas through reviewed pipelines ahead of deployment, so registrations are controlled and predictable rather than a side effect of application startup.

Q12Why do writes fail randomly even though the cluster looks healthy?

Often a secondary cannot reach the primary’s announced address, so writes succeed only when they happen to land on the primary. Check advertised host names, listener protocols, and network rules between instances.

Q13Is a managed registry service enough on its own?

It removes much of the operational burden, but you still own client configuration, access control, schema governance, backups, and your recovery expectations. Confirm the provider’s availability and failover behavior.

25Summary and Key Takeaways

The Schema Registry is a small service with a large responsibility: it holds the shared meaning of every record flowing through Kafka. Its high availability rests on a simple and elegant design. Durable storage lives in a replicated Kafka topic, many stateless instances serve reads from memory, and a single elected primary is the only writer so that schema IDs stay unique and ordered. Clients cache what they learn, which makes short outages survivable but makes cold starts and new schemas the fragile moments. Real availability comes from hardening the schemas topic, running several instances in separate zones, making sure they can reach each other, rolling changes one instance at a time, monitoring for a single healthy primary, and rehearsing regional failover with schema IDs preserved exactly. Follow these habits and the registry fades quietly into the background, which is exactly where infrastructure belongs.

Key Takeaways

  • The topic is the truth — schemas live in one replicated, compacted, single-partition Kafka topic, so the registry can never be more durable than that topic. Harden it first.
  • One writer, many readers — a single elected primary assigns IDs and writes, while every instance serves reads. More instances add read resilience, not write speed.
  • Run three instances in three zones — this survives failures and allows calm rolling upgrades, and every instance must share the same group identifier.
  • Caches hide outages until they cannot — warm clients keep working, but new clients, new schemas, and mass restarts expose registry problems immediately.
  • Make forwarding possible — each instance must announce a directly reachable address, or writes fail in confusing, intermittent ways.
  • Guard the regions and the IDs — use an active and standby design with non-eligible standby instances, preserve schema IDs exactly, and never allow two regions to write at once.
  • Watch, back up, and rehearse — alert on health, exactly one primary, and expiring certificates, keep independent backups, and practice failover before you need it.