Prompt

How do I handle schema versioning in an event streaming system?

Technology / Data Infrastructure1 observationLast seen Oct 24, 2026

Latest observation

Oct 24, 2026OpenAI APIWeb search: off

Schema versioning in an event streaming system is usually handled by combining compatibility rules, explicit versioning, and consumer-driven evolution. The main goal is to let producers and consumers evolve independently without breaking replay, consumers, or downstream integrations.

Core principles

1. Treat events as immutable

Once an event is published, it should never be changed in place. If the structure must change, publish a new schema version or a new event type.

2. Prefer additive changes

The safest changes are:

  • adding optional fields
  • adding new event types
  • adding new metadata
  • deprecating fields gradually

Avoid:

  • removing fields abruptly
  • changing field meaning
  • changing field type
  • renaming fields without compatibility support

3. Define compatibility policy

Pick and enforce a compatibility model for your schema registry or serialization format:

  • Backward compatible: new consumers can read old events
  • Forward compatible: old consumers can read new events
  • Full compatibility: both directions
  • Transitive compatibility: every new schema must remain compatible with all previous versions, not just the immediately prior one

For event streams, backward compatibility is especially important because consumers may replay old events from the log.


Common strategies

A. Schema registry with compatibility checks

Use a schema registry (e.g. Confluent Schema Registry, AWS Glue Schema Registry, Apicurio) and enforce compatibility at publish time.

Typical setup:

  • each event payload has a schema ID or version
  • producers register schemas before publishing
  • consumers fetch schema by ID/version
  • compatibility is validated automatically

This is the most common approach for Avro, Protobuf, and JSON Schema.

B. Version inside the event envelope

Add an explicit version field, for example:

{
  "eventType": "OrderCreated",
  "eventVersion": 2,
  "payload": {
    "orderId": "123",
    "customerId": "456",
    "currency": "USD"
  }
}

This helps when:

  • different versions of the same event need different parsing logic
  • you want to route by version
  • you need to support major schema changes

C. Use a stable envelope + versioned payload

Keep metadata stable and version only the payload:

{
  "id": "evt-1",
  "type": "OrderCreated",
  "occurredAt": "2026-10-24T12:00:00Z",
  "schemaVersion": 2,
  "data": { ... }
}

This reduces churn in downstream systems.

D. New event type for breaking changes

If a change is truly breaking, publish a new event type instead of mutating the old one:

  • UserCreated → UserCreatedV2
  • OrderPlaced → OrderSubmitted

This is often cleaner than forcing every consumer to handle incompatible payloads.


Best practices by schema format

Avro

  • Excellent for schema evolution
  • Supports default values for new fields
  • Strong compatibility rules
  • Use a registry and enforce transitive compatibility

Protobuf

  • Very good for evolution if you:
    • never reuse field numbers
    • reserve removed field numbers and names
    • use optional fields carefully
  • Great for compact binary streams

JSON Schema / JSON payloads

  • Easier to inspect and debug
  • Evolution requires discipline:
    • new fields should be optional
    • avoid changing field types
    • document required vs optional clearly
  • Often paired with a registry for validation

Consumer handling patterns

1. Be liberal in what you accept

Consumers should ignore unknown fields and tolerate missing optional fields.

2. Use defaults carefully

If a field is missing, consumer logic can provide a default. But make sure the default is semantically correct, not just technically valid.

3. Map versions to adapters

Create version-specific deserializers or translation layers:

  • OrderCreatedV1 -> InternalOrderEvent
  • OrderCreatedV2 -> InternalOrderEvent

Then downstream business logic uses one canonical internal model.

4. Normalize early

Convert external event versions into a single internal representation as soon as possible.


Recommended evolution workflow

  1. Design the event contract

    • fields, types, optionality, semantics
    • compatibility expectations
  2. Additive changes first

    • add new optional fields
    • keep old fields for compatibility
  3. Deprecate, don’t delete immediately

    • stop producing old fields
    • keep consuming them for a while
  4. Monitor consumers

    • identify who still relies on old versions
    • measure lagging consumers before removal
  5. Introduce a breaking version only when needed

    • if semantics or structure change significantly, create a new event type or major version

Practical rules of thumb

  • Never change the meaning of an existing field.
  • Never reuse a field name for a different meaning.
  • Never reuse Protobuf field numbers.
  • Prefer optional fields over required ones.
  • Make consumers resilient to unknown fields.
  • Keep event history replayable.
  • Use compatibility checks in CI/CD.
  • Document schema evolution rules for teams.

Example evolution

Version 1

{
  "orderId": "123",
  "amount": 42.50
}

Version 2, backward compatible

{
  "orderId": "123",
  "amount": 42.50,
  "currency": "USD"
}

Old consumers can ignore currency; new consumers can use it.

Version 3, breaking change

Instead of:

{ "amount": 42.50 }

You need:

{
  "total": {
    "value": 42.50,
    "currency": "USD"
  }
}

This may be better as a new event type or major version with adapters.


A solid default approach

If you want a robust baseline:

  • use a schema registry
  • enforce backward or transitive compatibility
  • make fields optional by default
  • keep a stable event envelope
  • version the payload
  • create new event types for breaking changes
  • add consumer adapters for old versions

If you want, I can also show:

  1. a Kafka + Avro versioning setup,
  2. a Protobuf evolution checklist, or
  3. a JSON event versioning pattern with example code.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.