Schema Registry is a standalone service that stores and versions the schemas of Kafka messages, and enforces compatibility rules when schemas change. Producers register a schema and send only a small schema ID with each message, and consumers use that ID to fetch the exact schema needed to decode it. This keeps messages compact and stops a producer from publishing data that would break downstream consumers.
Kafka itself treats message keys and values as opaque bytes. Schema Registry adds the missing contract between teams. Confluent Schema Registry is the best-known implementation, and it supports Avro, Protobuf and JSON Schema.
Without a contract, a producer can rename a field or change a type, and every consumer that reads the topic fails at runtime, often long after the change was deployed. Embedding the full schema in every message solves decoding but wastes bandwidth. A registry gives you three things at once: a central source of truth, small messages, and a gate that rejects incompatible changes before they reach the topic.
The registry stores schemas under a subject, usually named after the topic, such as orders-value. Every new, different schema for a subject receives a new version number, and every distinct schema has a globally unique ID.
Because both sides cache by ID, the registry is contacted only when a new schema appears, not for every message.
The compatibility setting decides which schema changes are allowed for a subject.
| Mode | Meaning | Typical safe change |
|---|---|---|
BACKWARD | New schema can read data written with the previous schema | Delete a field, add an optional field with a default |
FORWARD | Old schema can read data written with the new schema | Add a field, delete an optional field |
FULL | Both directions with the previous version | Add or remove optional fields with defaults |
BACKWARD_TRANSITIVE, FORWARD_TRANSITIVE, FULL_TRANSITIVE | The same check against all earlier versions | Long-lived topics replayed from the start |
NONE | No checking | Only for throwaway development topics |
BACKWARD is the default. It lets you upgrade consumers first and then producers, and it lets a new consumer replay old data. Choose a transitive mode for topics you replay from the beginning.
This Java producer uses the Confluent Avro serializer. The schema.registry.url property points the serializer at the registry.
The currency field has a default, so adding it later is a backward-compatible change. The consumer side uses KafkaAvroDeserializer with the same schema.registry.url.
The registry exposes a REST API on port 8081 by default. These calls cover most day-to-day checks.
Run the compatibility check in your CI pipeline so incompatible schemas fail the build rather than a production deploy. In production, turn off auto.register.schemas on producers and register schemas through the pipeline instead.
The registry keeps its state in a Kafka topic, normally _schemas, so it needs no separate database. Run at least two instances behind a load balancer, with one acting as primary for writes, and set the _schemas topic replication factor to 3. Secure it with TLS and authentication, since anyone who can write schemas can break your pipelines.
No. It is a separate service. Confluent Schema Registry is the common choice, and there are compatible alternatives, so check licensing and client support for the one you choose.
Avro is the traditional fit with compact binary encoding and strong evolution rules. Protobuf is a good choice if you already use it for gRPC. JSON Schema suits teams that must keep human-readable JSON.
It keeps decoding messages whose schema IDs it has already cached. Messages with unseen IDs fail until the registry is reachable again.
No. Only a 5-byte prefix, the magic byte and the schema ID, is added to each message.
Schema Registry gives Kafka a shared, versioned contract for message formats. Producers register schemas, messages carry only a schema ID, and consumers fetch and cache the matching schema. Compatibility rules such as BACKWARD and FULL block breaking changes early. Check compatibility in CI, disable auto-registration in production, and run the registry with replication and security.