← Lessons

quiz vs the machine

Gold1360

System Design

The Schema Registry

How a registry enforces compatible message schemas across producers and consumers.

5 min read · core · beat Gold to climb

The decoupling problem

Producers and consumers of a topic are deployed separately and evolve at different speeds. Without a shared contract, a producer change can break every downstream reader.

What the registry stores

A schema registry is a service that holds versioned schemas, often in Avro, Protobuf, or JSON Schema. Each schema gets an id. A producer registers its schema, then writes only the small id with each message instead of the full schema.

How reads work

A consumer reads the id from the message, fetches the matching schema from the registry, and uses it to deserialize. This keeps payloads small and the schema authoritative.

Compatibility checks

The registry enforces a compatibility rule when a new version is registered:

  • Backward lets new consumers read old data.
  • Forward lets old consumers read new data.
  • Full requires both.

A change that violates the rule is rejected before it can break consumers.

Key idea

A schema registry stores versioned schemas by id and enforces compatibility, so producers and consumers can evolve without breaking the message contract.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a producer write into each message when using a schema registry?

2. What does backward compatibility allow?