← Back to list

Event Schema Evolution Over Time

A Real Interview Deep Dive into Contracts, Compatibility, and Silent Production Failures

Arvind Kumar · 2026-01-29 04:01 · 2 claps · 4.6 min read paywalled
#kafka #apache-kafka #avro #kafka-schema-registry #event-driven-architecture
Open on Medium ↗
Wiki topics: 🎮 · Gaming 🏛️ · Architecture

Event Schema Evolution Over Time

A Real Interview Deep Dive into Contracts, Compatibility, and Silent Production Failures

Schema evolution is where Kafka systems either mature — or slowly rot.

Early on, events are simple. One team owns producers, one team owns consumers, and changes move fast.

Then the system grows:

  • more producers
  • more consumers
  • more teams
  • more “small changes”

And suddenly, a harmless-looking field change breaks production — quietly.

That’s why interviewers ask this question. It’s not about serialization formats. It’s about whether you understand that events are contracts, not code artifacts.

Full story for non-members | Microservices E-Book | Spring Boot E-Book | Join Whatsapp Group for Daily Tech Bytes | Youtube | LinkedIn

created with claude.ai

created with claude.ai

Parent story where all 10 interview scenario stories are at one place — link

Interviewer (Jai): Multiple teams publish to the same Kafka topic. Over time, fields are added and removed. How do you prevent breaking consumers?

Candidate (Sara): First, I stop treating events like internal DTOs.

Once multiple teams consume an event, it becomes a public contract — and contracts evolve very differently from code.

Jai: What goes wrong if teams don’t think that way?

Sara: They deploy a “small change” that compiles locally and breaks someone else at runtime.

Kafka won’t stop them. Kafka will happily deliver incompatible data.

That’s what makes this dangerous.

Why Kafka Makes Schema Problems Worse

Jai: Why is this harder in Kafka than in synchronous APIs?

Sara: Because producers and consumers are decoupled in time.

A REST API breaks immediately if the contract changes. Kafka breaks later, when:

  • a consumer restarts
  • lag catches up
  • replay happens
  • a new consumer is added

The failure is delayed and harder to trace.

First Principle: Producers and Consumers Evolve Independently

Jai: State your core assumption.

Sara: Producers and consumers deploy independently and cannot coordinate releases.

That single assumption drives everything else.

Jai: Explain.

Sara: A producer might deploy version N+1 while consumers are still on version N-2.

So every change must be safe across multiple versions at once.

The Event Contract Model

Jai: How do you model an event properly?

Sara: As an immutable record of something that happened — not as a reflection of my current database schema.

The event sits between teams. It must change slower than code.

Adding Fields: The “Easy” Case

Jai: Let’s get concrete. A team wants to add a new field. Safe?

Sara: Usually yes — if done correctly.

Consumers must:

  • ignore unknown fields
  • rely only on fields they understand

Producers must:

  • treat new fields as optional
  • not assume consumers will read them immediately

Jai: What breaks this?

Sara: When consumers assume strict schemas or deserialize rigidly.

Or when producers assume new fields are instantly mandatory.

Removing Fields: The Real Danger

Jai: What about removing a field?

Sara: That’s where most systems break.

A field that seems unused may still be:

  • consumed by a slow consumer
  • used during replay
  • relied on by an offline job

Removing it breaks behavior, not compilation.

Jai: So what do you do instead?

Sara: Deprecate, don’t delete.

Fields live longer than teams expect.

Diagram: Safe vs Unsafe Evolution

Additive changes are survivable. Subtractive changes require migrations.

Schema Registry Enters the Picture

Jai: How do you enforce discipline across teams?

Sara: With schema validation at write time.

A centralized schema registry prevents producers from publishing incompatible data.

Jai: What exactly does it enforce?

Sara: Compatibility rules.

Before a producer publishes a new schema, it’s checked against existing versions.

If it violates compatibility guarantees, the write is rejected.

Compatibility Is a Business Decision

Jai: Which compatibility mode do you choose?

Sara: It depends on the contract.

  • Backward compatibility if consumers lag behind producers
  • Forward compatibility if consumers upgrade first
  • Full compatibility for shared, long-lived topics

The key is choosing intentionally — not defaulting blindly.

What Compatibility Does Not Solve

Jai: Does schema compatibility guarantee correctness?

Sara: No.

It guarantees deserialization safety, not semantic correctness.

You can evolve a schema compatibly and still break business logic.

Semantic Breakage Example

Jai: Give me an example.

Sara: Changing a field meaning without changing its name.

For example:

  • status = ACTIVE used to mean “user logged in”
  • now it means “subscription active”

Schema didn’t break. Logic did.

Kafka won’t help you here.

Versioning Events Explicitly

Jai: How do you protect against semantic drift?

Sara: By versioning meaning, not just structure.

Some teams embed:

  • eventVersion
  • schemaVersion
  • or use separate topics per major version

This trades simplicity for safety.

Replay Is the Ultimate Test

Jai: Why does replay make this worse?

Sara: Because replay reintroduces old data into new code.

If your consumer logic can’t handle historical events, replay becomes dangerous — which defeats Kafka’s core advantage.

Governance Beats Tooling

Jai: Is Schema Registry enough?

Sara: No.

Tooling enforces structure. Governance enforces behavior.

Teams need:

  • ownership of topics
  • review for breaking changes
  • clear deprecation policies

Without this, schema rules are bypassed under pressure.

The Silent Failure Mode

Jai: What’s the worst failure you’ve seen?

Sara: A consumer silently ignoring fields it thought were optional — but weren’t.

No crashes. No alerts. Just wrong data for weeks.

Those are the hardest bugs to find.

One-Line Philosophy

Jai: Summarize your approach.

Sara: Events are not messages. They’re promises. Breaking them breaks trust.

Closing Thought

Kafka gives teams freedom:

  • independent deployment
  • replayability
  • decoupled scaling

Schema evolution is the price of that freedom.

If events are treated casually, Kafka becomes a delivery system for broken assumptions.

If events are treated as contracts, Kafka becomes one of the most resilient integration platforms available.

Key Concepts Covered

  • Events as long-lived contracts, not DTOs
  • Independent evolution of producers and consumers
  • Additive vs breaking schema changes
  • Why field removal is dangerous
  • Role and limits of schema registries
  • Compatibility modes and trade-offs
  • Semantic vs structural compatibility
  • Replay as the ultimate validation
  • Governance beyond tooling

Liked this deep dive story? If Yes Please 👏 Clap(50) | 📤 Share | 🔔 Follow

=======

Below is a collection of all the stories in one place

[embed]List: Apache Kafka | Kafka Deep Dive | Kafka Interview Questions | Curated by Arvind Kumar | Medium Apache Kafka | Kafka Deep Dive | Kafka Interview Questions · All about Kafka and its real world use cases. If you…codefarm0.medium.com


메타데이터
post_id
3ea45e12dc9e
slug
event-schema-evolution-over-time-3ea45e12dc9e
url
https://medium.com/@codefarm0/event-schema-evolution-over-time-3ea45e12dc9e
canonical_url
https://medium.com/@codefarm0/event-schema-evolution-over-time-3ea45e12dc9e
author_url
https://medium.com/@codefarm0
status
ok
fetched_at
2026-06-09 15:37:30