Registry and subject strategies
What happens when the schema registry is down?
Why a registry exists
A schema registry exists for a coordination reason. Without a central authority, every producer must negotiate with every consumer: that is N × M agreements. With a central reference, each producer registers once and each consumer checks once: N + M agreements.
Subject strategy: the unit of the contract
The subject strategy is the granularity of the contract: which set of messages must be compatible with each other. (In a registry, a subject is the name under which a series of schema versions is stored.) Three common choices:
| Strategy | The interface is | Good | Cost |
|---|---|---|---|
| Per topic | the stream | simple | a topic cannot carry mixed types |
| Per record type | the record type | one type can travel across several topics, one topic can carry several types | consumers must handle a union; ordering across types now matters |
| Per topic and per type | both | the benefits of both | more bookkeeping |
The derivation is not a matter of taste: match the contract granularity to the unit a consumer subscribes to. When the subscription unit and the contract unit differ, you get the situation "I cannot evolve this without breaking an unrelated consumer".
Availability: the neglected part
Two common registry behaviours put it in the data path:
- validate on register: the producer asks the registry before it publishes a new schema,
- decode by ID on read: a consumer reads a schema ID in each message and fetches the schema from the registry.
If the registry fails, one of two things happens:
- Fail closed: the producer stops. A metadata service now limits the availability of ingestion. (This was Sara's 40-minute outage.)
- Fail open with a cache: the producer continues with the last known schema. That admits unvalidated schemas and defers the discovery of any problem.
Every workable deployment caches decode aggressively and makes registration rare. This is the general move of putting the authority on the change path and keeping it off the data path. It is the same structural choice as using manifest metadata instead of directory listing in a table format (the manifest says which files belong, and nobody lists the folder on every query).
A registry turns N×M agreements into N+M at the price of a metadata service in the data path. Cache the decode; keep only registration synchronous.