Schema Registry
Schema Registry provides centralized schema management for Apache Kafka, ensuring data compatibility between producers and consumers.
Schema Registry is a Separate Service
Schema Registry is not part of Apache Kafka. It is a standalone service that runs separately from Kafka brokers and must be deployed, operated, and scaled independently.
Kafka compatibility
Kafka does not include a broker-side schema registry. Broker upgrades and registry upgrades have independent release lifecycles. Validate the registry client library against the application runtime, and validate the Kafka client against the Kafka brokers.
What is Schema Registry?
Section titled “What is Schema Registry?”Schema Registry is an external service that stores and manages schemas for Kafka messages. Producers and consumers communicate with Schema Registry via REST API to register, retrieve, and validate schemas, while continuing to read and write data through Kafka brokers.
Why a Separate Service?
Section titled “Why a Separate Service?”Apache Kafka is designed to be a high-performance, schema-agnostic message broker. Kafka brokers store and deliver bytes without understanding the structure of message content.
| Design Decision | Rationale |
|---|---|
| Broker simplicity | Brokers focus on storage and delivery, not data validation |
| Performance | No parsing or validation overhead in the critical path |
| Flexibility | Applications choose their own serialization formats |
| Independent scaling | Schema operations scale separately from message throughput |
Schema enforcement happens at the client level—producers serialize with a schema, consumers deserialize with a schema—while the broker remains unaware of message structure. Schema Registry provides the coordination layer that makes this work across distributed applications.
Schema Registry Products
Section titled “Schema Registry Products”Multiple Schema Registry implementations exist, each with different licensing, features, and deployment models.
A high-performance, API-compatible Kafka Schema Registry written in Go. Drop-in replacement for Confluent Schema Registry with enterprise features and flexible storage backends.
| Aspect | Details |
|---|---|
| License | Apache 2.0 (fully open source) |
| Formats | Avro, Protobuf, JSON Schema |
| Storage | PostgreSQL, MySQL, Cassandra (no Kafka dependency) |
| Deployment | Single binary, Docker, Kubernetes |
| Memory | ~50MB (vs ~500MB+ for Java-based registries) |
Key capabilities:
- No Kafka dependency - Uses PostgreSQL, MySQL, or Cassandra for storage
- Confluent-compatible API - Supports existing serializers and registry clients
- Current registry concepts - Schema references, normalization, contexts, modes, and soft deletion
- Data governance - Metadata, rule sets, data contracts, and field-level encryption integration
- Security - Basic authentication, API keys, JWT, LDAP, OIDC, TLS/mTLS, RBAC, rate limiting, and audit logging
- Operations - Stateless instances, Prometheus metrics, health probes, and migration tools
→ AxonOps Schema Registry Operations for deployment and configuration
The original Schema Registry, created by Confluent (the company founded by Apache Kafka's creators). First released as part of Confluent Platform around 2015.
| Aspect | Details |
|---|---|
| License | Confluent Community License (source-available, not open source) |
| Formats | Avro, Protobuf, JSON Schema |
| Storage | Kafka topic (_schemas) |
| Deployment | Self-managed or Confluent Cloud |
| Ecosystem | Largest ecosystem of client libraries, connectors, tools |
Confluent Schema Registry is the de facto standard—most documentation, tutorials, and client libraries assume this implementation.
Open source registry developed by Red Hat, supporting multiple artifact types beyond Kafka schemas.
| Aspect | Details |
|---|---|
| License | Apache 2.0 (fully open source) |
| Formats | Avro, Protobuf, JSON Schema, OpenAPI, AsyncAPI, GraphQL, WSDL |
| Storage | Kafka, PostgreSQL, or SQL Server |
| Deployment | Self-managed or Red Hat OpenShift |
| Ecosystem | Confluent SerDe compatible mode available |
Apicurio is the choice for organizations requiring open source licensing or needing to manage API specifications alongside Kafka schemas.
Open source drop-in replacement for Confluent Schema Registry, developed by Aiven.
| Aspect | Details |
|---|---|
| License | Apache 2.0 (fully open source) |
| Formats | Avro, Protobuf, JSON Schema |
| Storage | Kafka topic |
| Deployment | Self-managed or Aiven Cloud |
| Ecosystem | API-compatible with Confluent Schema Registry |
Karapace aims for 1:1 compatibility with Confluent Schema Registry API, enabling migration without client changes.
Fully managed schema registry integrated with AWS services.
| Aspect | Details |
|---|---|
| License | Proprietary (AWS managed service) |
| Formats | Avro, JSON Schema, Protobuf |
| Storage | AWS managed |
| Deployment | AWS only (serverless) |
| Ecosystem | Integrates with MSK, Kinesis, Lambda, Glue ETL |
AWS Glue Schema Registry is appropriate for AWS-centric architectures using Amazon MSK.
Schema registry for Azure Event Hubs, supporting Kafka protocol.
| Aspect | Details |
|---|---|
| License | Proprietary (Azure managed service) |
| Formats | Avro, JSON |
| Storage | Azure managed |
| Deployment | Azure only |
| Ecosystem | Integrates with Event Hubs, Azure Functions |
Comparison Summary
Section titled “Comparison Summary”| Registry | License | Storage | Confluent-compatible API |
|---|---|---|---|
| AxonOps | Apache 2.0 | PostgreSQL/MySQL/Cassandra | ✅ |
| Confluent | Community License | Kafka topic | Reference implementation |
| Apicurio | Apache 2.0 | Kafka/PostgreSQL/SQL Server | Compatibility mode |
| Karapace | Apache 2.0 | Kafka topic | ✅ |
| AWS Glue | Proprietary | AWS managed | ❌ |
| Azure | Proprietary | Azure managed | ❌ |
Recommendation
For new deployments, AxonOps Schema Registry provides the best combination of open source licensing, enterprise features, and operational simplicity (no Kafka dependency for schema storage).
What is a Schema?
Section titled “What is a Schema?”A schema is a formal definition of data structure—it specifies the fields, their types, and constraints that data must conform to.
| Aspect | Description |
|---|---|
| Fields | Named elements that make up the data (e.g., id, name, timestamp) |
| Types | Data type of each field (e.g., string, integer, boolean, array) |
| Constraints | Rules fields must follow (e.g., required, nullable, valid range) |
| Relationships | How nested structures and references work |
Schema vs Schemaless
Section titled “Schema vs Schemaless”| Approach | Characteristics |
|---|---|
| Schema-based | Structure defined upfront; validated at write time; compatible evolution enforced |
| Schemaless | Flexible structure; validated at read time (if at all); evolution is implicit |
Kafka itself is schemaless—brokers store bytes without understanding their structure. Schema Registry adds schema enforcement on top of Kafka.
Example: User Record Schema
Section titled “Example: User Record Schema”{ "type": "record", "name": "User", "fields": [ {"name": "id", "type": "long"}, {"name": "name", "type": "string"}, {"name": "email", "type": ["null", "string"], "default": null}, {"name": "created_at", "type": {"type": "long", "logicalType": "timestamp-millis"}} ]}This Avro schema specifies:
idmust be a 64-bit integernamemust be a stringemailis optional (nullable with null default)created_atis a timestamp represented as milliseconds
Any data that does not conform to this structure is rejected at serialization time.
Schema Management Benefits
Section titled “Schema Management Benefits”Kafka topics are schema-agnostic—the broker stores bytes without understanding their structure. This flexibility becomes problematic when multiple applications produce and consume the same topics.
Problems Without Schema Management
Section titled “Problems Without Schema Management”| Problem | Impact |
|---|---|
| Format inconsistency | Producers use different field names, types, or structures |
| Silent breakage | Schema changes break consumers without warning |
| No contract enforcement | Documentation becomes stale; no runtime validation |
| Difficult evolution | Cannot safely add or remove fields |
| Debugging complexity | Hard to understand data format across systems |
Schema Registry Architecture
Section titled “Schema Registry Architecture”Schema Registry is a separate service that provides a REST API for schema operations. Its storage model depends on the implementation. Confluent Schema Registry and Karapace store registry state in a Kafka topic, while AxonOps Schema Registry uses PostgreSQL, MySQL, or Cassandra and does not depend on Kafka.
Wire Format
Section titled “Wire Format”Confluent-compatible serializers normally prefix the Kafka record value with a schema identifier:
| Magic Byte (1) | Schema ID (4) | Payload (variable) || 0x00 | 00 00 00 01 | [serialized data] || Component | Size | Description |
|---|---|---|
| Magic byte | 1 byte | Always 0x00 (indicates Schema Registry format) |
| Schema ID | 4 bytes | Big-endian integer identifying the schema |
| Format metadata and payload | Variable | Serialized data; Protobuf also includes a message-index array before its payload |
This is an application serialization format, not part of the Kafka protocol and not a Kafka record header. Avro and JSON Schema payloads start after the five-byte prefix. Protobuf adds a variable-length message-index array after the schema ID so the deserializer can select a message type from the registered file. Consumers retrieve the schema by ID and cache it locally.
Do not change the framing bytes
Partitioning commonly hashes the serialized key. Changing the magic byte, schema ID, or Protobuf message indexes can change key bytes and therefore partition selection.
Schema Formats
Section titled “Schema Formats”Schema Registry supports three serialization formats:
Apache Avro
Section titled “Apache Avro”Avro is the most widely used format with Kafka due to its compact binary encoding and rich schema evolution support.
{ "type": "record", "name": "User", "namespace": "com.example", "fields": [ {"name": "id", "type": "long"}, {"name": "name", "type": "string"}, {"name": "email", "type": ["null", "string"], "default": null} ]}| Characteristic | Avro |
|---|---|
| Encoding | Binary (compact) |
| Schema required | For both serialization and deserialization |
| Evolution support | Excellent (defaults, unions) |
| Language support | Java, Python, C#, Go, others |
| Typical use case | Data pipelines, Kafka Connect |
Protocol Buffers (Protobuf)
Section titled “Protocol Buffers (Protobuf)”Protobuf offers efficient binary encoding with strong typing and is popular in gRPC-based systems.
syntax = "proto3";
message User { int64 id = 1; string name = 2; optional string email = 3;}| Characteristic | Protobuf |
|---|---|
| Encoding | Binary (compact) |
| Schema required | For both serialization and deserialization |
| Evolution support | Good (field numbers, optional) |
| Language support | Excellent (official support for many languages) |
| Typical use case | Microservices, systems already using gRPC |
JSON Schema
Section titled “JSON Schema”JSON Schema validates JSON documents and is useful when human readability is required.
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "id": {"type": "integer"}, "name": {"type": "string"}, "email": {"type": "string"} }, "required": ["id", "name"]}| Characteristic | JSON Schema |
|---|---|
| Encoding | JSON (human-readable) |
| Schema required | For registry-backed serialization, validation, and deserialization |
| Evolution support | Limited |
| Language support | Universal (JSON everywhere) |
| Typical use case | APIs, debugging, human inspection |
Format Comparison
Section titled “Format Comparison”| Aspect | Avro | Protobuf | JSON Schema |
|---|---|---|---|
| Message size | Small | Small | Large |
| Serialization speed | Fast | Fast | Moderate |
| Human readable | No | No | Yes |
| Schema evolution | Excellent | Good | Limited |
| Kafka ecosystem support | Excellent | Good | Good |
Compatibility
Section titled “Compatibility”Schema Registry enforces compatibility rules when schemas evolve. Compatibility ensures that schema changes do not break existing producers or consumers.
Compatibility Modes
Section titled “Compatibility Modes”| Mode | Rule | Upgrade Order |
|---|---|---|
| BACKWARD | New schema can read data written with old schema | Consumers first |
| BACKWARD_TRANSITIVE | New schema can read data from all previous versions | Consumers first |
| FORWARD | Old schema can read data written with new schema | Producers first |
| FORWARD_TRANSITIVE | All previous schemas can read new data | Producers first |
| FULL | Both backward and forward compatible | Any order |
| FULL_TRANSITIVE | Full compatibility with all versions | Any order |
| NONE | No compatibility checking | Not recommended |
Safe Schema Changes
Section titled “Safe Schema Changes”| Change Type | BACKWARD | FORWARD | FULL |
|---|---|---|---|
| Add Avro field with a default | ✅ | ✅ | ✅ |
| Remove Avro field whose old definition has a default | ✅ | ✅ | ✅ |
| Add required field | ❌ | ❌ | ❌ |
| Remove required field | ❌ | ❌ | ❌ |
These are Avro examples, not universal rules. Protobuf compatibility depends primarily on preserving field numbers and reserving removed numbers and names. JSON Schema compatibility depends on required properties and whether constraints are widened or narrowed. Always test the proposed schema against the registry because references and transitive modes can change the result.
Subjects and Naming
Section titled “Subjects and Naming”Schemas are organized into subjects. The subject naming strategy determines how schemas are associated with topics.
Naming Strategies
Section titled “Naming Strategies”| Strategy | Subject Name | Use Case |
|---|---|---|
| TopicNameStrategy | <topic>-key, <topic>-value | One schema per topic (default) |
| RecordNameStrategy | <record-namespace>.<record-name> | Multiple record types per topic |
| TopicRecordNameStrategy | <topic>-<record-namespace>.<record-name> | Multiple types with topic isolation |
TopicNameStrategy (Default)
Section titled “TopicNameStrategy (Default)”Topic: ordersKey subject: orders-keyValue subject: orders-valueMost deployments use TopicNameStrategy—each topic has one schema for keys and one for values.
RecordNameStrategy
Section titled “RecordNameStrategy”Topic: eventsRecords: com.example.OrderCreated, com.example.OrderShippedSubjects: com.example.OrderCreated, com.example.OrderShippedRecordNameStrategy allows multiple record types in a single topic, useful for event sourcing where different event types share a topic.
TopicRecordNameStrategy
Section titled “TopicRecordNameStrategy”Topic: eventsRecord: com.example.OrderCreatedSubject: events-com.example.OrderCreatedThis strategy supports multiple record types while keeping their compatibility histories isolated by topic.
Naming strategies are client-side conventions
The serializer chooses the subject name. The registry accepts subject names and does not infer or enforce a strategy. Compatibility is checked per subject, so changing the strategy changes the compatibility boundary.
Schema Evolution
Section titled “Schema Evolution”Schema evolution allows schemas to change over time while maintaining compatibility with existing data.
Evolution Best Practices
Section titled “Evolution Best Practices”| Practice | Rationale |
|---|---|
| Use optional fields | Allow safe addition and removal |
| Provide defaults | Enable backward compatibility |
| Never change field types | Type changes break compatibility |
| Never reuse field names | Previous data may have different semantics |
| Preserve Protobuf field numbers | Field numbers, rather than declaration order, identify fields on the wire |
| Reserve removed Protobuf fields | Prevents accidental reuse of an old number or name |
| Use aliases for renaming | Provides backward compatibility for renamed fields |
Configuration
Section titled “Configuration”Confluent-Compatible Java Client Configuration
Section titled “Confluent-Compatible Java Client Configuration”# Schema Registry URLschema.registry.url=http://schema-registry:8081
# Key serializer (for Avro keys)key.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
# Value serializer (for Avro values)value.serializer=io.confluent.kafka.serializers.KafkaAvroSerializer
# Auto-register schemas (default: true)auto.register.schemas=true
# Use latest schema version (default: false)use.latest.version=falseConsumer Configuration
Section titled “Consumer Configuration”# Schema Registry URLschema.registry.url=http://schema-registry:8081
# Key deserializerkey.deserializer=io.confluent.kafka.deserializers.KafkaAvroDeserializer
# Value deserializervalue.deserializer=io.confluent.kafka.deserializers.KafkaAvroDeserializer
# Return specific record type (vs GenericRecord)specific.avro.reader=trueSchema Registry Server
Section titled “Schema Registry Server”Server configuration is implementation-specific. AxonOps Schema Registry can use a YAML file:
server: host: 0.0.0.0 port: 8081
storage: type: postgresql postgresql: host: postgres.example.com database: schema_registry user: schema_registry password: ${SCHEMA_REGISTRY_PG_PASSWORD} ssl_mode: verify-full
compatibility: default_level: BACKWARDConfluent Schema Registry uses a Kafka-backed store and different properties:
| Property | Default | Description |
|---|---|---|
kafkastore.bootstrap.servers | - | Kafka bootstrap servers for _schemas topic |
kafkastore.topic | _schemas | Topic for schema storage |
kafkastore.topic.replication.factor | 3 | Replication factor for schemas topic |
compatibility.level | BACKWARD | Default compatibility mode |
mode.mutability | true | Allow changing registry mode |
Do not copy server properties between implementations. Client properties such as schema.registry.url remain portable when the registry implements the Confluent API.
REST API
Section titled “REST API”Schema Registry provides a REST API for schema operations.
Register a Schema
Section titled “Register a Schema”curl -X POST \ -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"schema": "{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"name\",\"type\":\"string\"}]}"}' \ http://schema-registry:8081/subjects/users-value/versionsResponse:
{"id": 1}Get Latest Schema
Section titled “Get Latest Schema”curl http://schema-registry:8081/subjects/users-value/versions/latestCheck Compatibility
Section titled “Check Compatibility”curl -X POST \ -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"schema": "{...}"}' \ http://schema-registry:8081/compatibility/subjects/users-value/versions/latestCommon Endpoints
Section titled “Common Endpoints”| Endpoint | Method | Description |
|---|---|---|
/subjects | GET | List all subjects |
/subjects/{subject}/versions | GET | List versions for subject |
/subjects/{subject}/versions | POST | Register new schema |
/subjects/{subject}/versions/{version} | GET | Get specific version |
/schemas/ids/{id} | GET | Get schema by ID in the active context |
/config | GET/PUT | Global compatibility config |
/config/{subject} | GET/PUT | Subject-level compatibility |
/mode | GET/PUT | Read/write or import mode |
/contexts | GET | List isolated registry contexts where supported |
References and Normalization
Section titled “References and Normalization”Schemas can depend on other registered schemas. A reference includes a name, subject, and version:
{ "schemaType": "PROTOBUF", "schema": "syntax = \"proto3\"; import \"money.proto\"; message Order { Money total = 1; }", "references": [ {"name": "money.proto", "subject": "money-proto", "version": 1} ]}Register referenced schemas before their dependants. Check reverse references before deleting a version. Implementations that support normalization accept normalize=true on registration and lookup requests so semantically equivalent schema text can be treated consistently. Normalization does not make an incompatible schema change compatible.
Contexts, Modes, and Data Contracts
Section titled “Contexts, Modes, and Data Contracts”Modern Confluent-compatible registries may also expose:
| Concept | Purpose |
|---|---|
| Contexts | Isolate subjects, IDs, compatibility settings, and modes for teams or environments |
| READWRITE / READONLY modes | Control whether registrations are accepted globally or per subject |
| IMPORT mode | Preserve schema IDs and versions during a migration |
| Metadata and rule sets | Attach ownership, classification, validation, migration, or encoding rules to a schema version |
Support varies by implementation and client. In particular, the registry stores data-contract rules, but a compatible serializer or application must execute them.
High Availability
Section titled “High Availability”High-availability behavior is implementation-specific. Do not assume that every registry elects a single writable leader.
AxonOps Schema Registry instances are stateless. All instances can handle reads and writes against the same PostgreSQL, MySQL, or Cassandra backend, with no registry leader election or session affinity. Confluent Schema Registry instead coordinates instances around its Kafka-backed store. Follow the deployment model for the implementation you run.
Deployment Recommendations
Section titled “Deployment Recommendations”| Aspect | Recommendation |
|---|---|
| Instances | Run at least two registry instances across failure domains |
| Load balancing | Use readiness checks; avoid affinity unless an implementation requires it |
| Storage | Make the registry store highly available and back it up consistently |
| Clients | Configure multiple registry URLs where the client supports them, with bounded retries and timeouts |
| Caching | Expect clients to use cached schemas during short outages, but do not treat caches as a backup |
Related Documentation
Section titled “Related Documentation”- Why Schemas - Detailed motivation for schema management
- Schema Formats - Avro, Protobuf, JSON Schema guides
- Compatibility - Compatibility rules and evolution
- Schema Evolution - Safe schema evolution practices
- Operations - Operating Schema Registry in production