The interview problem
Design a schema registry for 500 event-producing services and consumers that may replay a year of retained events. Prevent incompatible releases, support rolling upgrades and keep decoding working during a registry outage. Explain why a schema-compatible change can still break the business.
Original system-design practice, not a reported interview. Scale assumptions are hypothetical. Examples use Avro-style reader/writer resolution; other formats need their own compatibility rules. Primary specification retrieved September 27, 2026.
1. Keep schema identity immutable
Each event carries an envelope identifying its format and exact writer schema ID, alongside event identity and payload. A schema ID resolves to an immutable schema definition and pinned references. Never interpret historical bytes with whichever schema happens to be newest today.
Separate schema identity from the subject under which a schema is governed. A subject might represent a particular event type and namespace, with ordered versions, owners and a compatibility policy. One topic can carry several event types; define naming conventions so unrelated types do not accidentally share one evolution history.
Keep the full schema and policy-relevant metadata. A parsing fingerprint may omit attributes useful to evolution checks or documentation, so do not substitute a hash of a reduced representation for the complete governance record. Verify content equality when deduplicating, with a documented normalization algorithm.
2. Define the direction before saying compatible
Use these explicit definitions: backward compatibility means the new reader can read data written with old schemas; forward compatibility means old readers can read data written with the new schema. Full compatibility requires both. Transitive checks compare against all retained supported versions, not just the immediately previous version.
Suppose version 1 has order_id as a string. Version 2 adds source as a string with reader default “unknown.” A version-2 reader can supply that default when reading a version-1 record. A version-1 reader can ignore the extra writer field in version-2 data. Under the stated Avro record-resolution rules and unchanged record identity, that addition supports both directions.
If source has no default, the new reader cannot resolve an old record missing it: backward compatibility fails. A field default is used during resolution of missing writer data; it does not mean producers can omit that field from every record they encode using a schema that includes it.
For another example, change quantity from int to long. A new long reader can accept old int data, but an old int reader does not generally accept a long writer. Some sample values fitting in 32 bits do not make the schema pair forward-compatible. Test the format's rules, not a handful of convenient payloads.
3. Make replay part of the contract
Version 1 contains order_id. Version 2 adds source with a default. Version 3 keeps source but removes its default. A version-3 reader can read version-2 records because their writer schema includes source. It cannot read version-1 records that lack source. Checking only the immediately preceding version misses the year-old replay failure.
Choose compatibility scope from retained data and supported consumer lifetimes. If all retained versions must remain readable, use transitive backward checks for the new reader. If old consumers must process new events during a rolling upgrade, also enforce the relevant forward checks. These are related but different obligations.
Incompatible evolution may require a new event type, a dual-write migration or a translation layer. Dual writes need event identities and consumer rules to avoid double counting. Translating old records must preserve provenance and distinguish an inferred default from a genuinely observed value.
4. Serialize registration, cache immutable reads
Use an authenticated registry API, a format-specific validation service and a durable metadata store. Registration parses the candidate, resolves pinned dependencies, checks compatibility against the subject policy and commits a new version. The commit verifies the subject head and policy revision have not changed since validation; otherwise retry validation. This prevents two concurrent registrations from both validating against a stale head.
Expose lookup by immutable schema ID, subject/version lookup, dry-run compatibility checks and audited policy changes. Producers register through CI before deployment and pin the approved ID. Consumers cache schemas by immutable ID. Restrict who can relax compatibility policy; a passing check against a silently weakened policy is weak evidence.
Dry-run success is not a reservation. Return the versions and policy used in the result, then recheck at registration. Libraries should report unknown IDs and resolution failures distinctly so an operator can distinguish an unavailable registry from corrupt or incompatible data.
5. Keep outages from becoming data corruption
A registry outage need not stop decoding schemas already cached locally. Bundle required schemas or warm caches before rollout. An unknown ID should trigger bounded retries and controlled buffering or quarantine, not guessing a schema from payload shape or silently dropping events.
Store writer schemas with long-lived archives or maintain a durable dependency on the registry's retained records. Keep schema definitions at least as long as data and backup restore paths require them. Deleting a subject from a UI must not casually destroy the only decoder for historical bytes.
After disaster recovery, prevent ID reuse and verify mappings against archived manifests. A restored registry that maps an old numeric ID to different bytes is more dangerous than an unavailable registry. Pin referenced schemas so a dependency update cannot change an existing schema's meaning.
6. Calculate the read-path difference
Assume 500 subjects with 100 versions each and an average full schema size of 10 KB. Raw schema content is 50,000 × 10 KB = 500 MB, before indexes, references, audit history and replication. Metadata volume is modest compared with event traffic, but availability and immutable identity are critical.
At 100,000 events/s, performing one remote lookup per event creates 100,000 registry requests/s. With a hypothetical 99.9% cache hit rate, misses fall to 100/s in steady state. That average hides cold starts: 1,000 consumers loading 50 schemas each can produce 50,000 lookups during a simultaneous restart.
Use startup warming, bounded concurrency, request coalescing and jitter to reduce that burst. A 500 MB global catalog does not imply every consumer should load all schemas; cache the dependencies it needs. Measure large schemas and reference depth, and impose limits so malicious registrations cannot exhaust validation resources.
7. Validate meaning outside the type system
Changing amount from cents to dollars while keeping the same numeric type can pass structural compatibility and still distort reported revenue by a factor of 100. Changing an enum's meaning, timezone convention or identifier scope has similar risks. Document units and semantics, use contract fixtures and involve affected owners in migrations.
Test old-writer/new-reader and new-writer/old-reader combinations as required, plus replay from the oldest supported schema. Include defaults, unknown enum values, unions and nested references. A registry can enforce structural policy; it cannot prove downstream business code handles every newly valid value correctly.
Foundation: state compatibility direction in reader/writer terms. Senior: explain the three-version replay counterexample. Staff: recover immutable IDs and migrate a semantics change without double counting.
Score 0–2 each for schema identity, directional examples, replay policy, registration concurrency and semantic migration. Continue with CDC pipelines and durable queues.
Sources and next steps
- Apache Avro 1.12 specification — writer/reader schema resolution, defaults and numeric promotion.
The registry architecture, migration examples and sizing are original. Compatibility behavior is format-specific; do not apply these Avro examples unchanged to Protobuf or JSON Schema.
Continue your preparation
Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.