Scrivio Interview library
DesignAdvanced7 min read · updated 12 November 2026

Your company publishes events on Kafka consumed by dozens of teams in several languages. Choose a serialization format and compatibility policy, and explain how you would enforce it.

I would use a schema-based format, Protobuf or Avro, with a schema registry, and set a compatibility mode per subject in the registry, FULL_TRANSITIVE for widely shared topics and at least BACKWARD_TRANSITIVE elsewhere. Enforcement happens before deployment: CI checks every schema change against the registry and blocks incompatible ones, producers do not auto-register schemas in production, and shared schemas live in one repository reviewed by producing and consuming teams. The evolution rules are written down: add optional fields, never reuse field numbers or change types, and JSON Schema remains an option where readability matters more than size.

Why this question is asked

When one team publishes events that dozens of teams consume, in Java, Python, Go and more, the event format becomes a public contract. A careless change, such as renaming a field or changing a number to a string, can break consumers that the producing team has never heard of, often hours later when the new message finally reaches them. Interviewers ask this design question to see whether we can choose a format for many languages, pick the right compatibility guarantee, and enforce it with tooling instead of hope. In this answer, we will recap how a schema registry works with Kafka, choose the format, work out which compatibility mode we need, describe the enforcement pipeline and the evolution rules, and set up ownership.

1A Quick Recap of Schema Registries With Kafka

Kafka itself stores bytes; it does not know or care what is in a message. A schema registry, such as Confluent Schema Registry or Apicurio, is a separate service that stores versions of schemas under a name called a subject, by default the topic name plus -value. When a producer serializes a message, its serializer looks up the schema's id in the registry and writes a few header bytes, a magic byte and a 4-byte schema id, before the payload. A consumer's deserializer reads the id, fetches that schema version from the registry, caches it, and decodes the payload.

The registry does one more job, which is the heart of this design: when someone registers a new version of a schema, it checks the new version against earlier ones using the subject's compatibility mode, and refuses it if the change would break the agreed guarantee.

Step throughProducing and consuming with a registry
ProducerSchema registryKafka topicConsumer
look up id for OrderPlaced v4
id 271
magic byte + id 271 + Protobuf payload
poll
message bytes
fetch schema 271 (cached afterwards)
OrderPlaced v4 schema

7 messages in order. Play them, or step through them one at a time.

2Choosing the Format

With dozens of consuming teams in several languages, the format needs good code generation and libraries everywhere, compact messages at high volume, and well-defined evolution rules. Both Protobuf and Avro qualify, and both are supported by the main registries. Protobuf has the broader multi-language tooling and is often already used for gRPC, so teams know it; Avro has excellent support in the data ecosystem, such as Kafka Connect, Spark and data lakes, and resolves fields by name using the writer's schema. Either is a good answer; what matters is choosing one as the default for the company, so tooling, libraries and knowledge are shared.

I would choose Protobuf as the default here because of the many languages, and allow JSON Schema for topics whose consumers value readability over size, such as low-volume integration topics or topics read by people during support. JSON Schema subjects get the same registry checks, so the policy does not split in two.

3Choosing the Compatibility Mode

Compatibility modes describe who can read whom. BACKWARD means a consumer using the new schema can read data written with the previous one, so consumers upgrade first. FORWARD means data written with the new schema can be read by consumers still on the previous one, so producers can upgrade first. FULL means both. The _TRANSITIVE variants check against all earlier versions, not only the latest, which matters on Kafka because topics may keep months of old messages that a new consumer replays from the beginning.

On a shared topic, the producer changes the schema and dozens of consumers upgrade whenever they get to it, so old consumers must read new data: that needs forward compatibility. New consumers, or consumers replaying history, must read old data: that needs backward compatibility across every version. So for widely shared topics I would set FULL_TRANSITIVE per subject. It is the strictest mode, and in practice it limits changes to adding or removing optional fields, which is exactly the discipline a public contract needs. Topics with a single, closely coordinated consumer can use BACKWARD_TRANSITIVE.

Compatibility modes on a shared topic
ModeGuaranteeUpgrade order
BACKWARDnew schema reads data from the previous versionconsumers first
FORWARDprevious schema reads data from the new versionproducers first
FULLboth, against the previous versionany order
FULL_TRANSITIVEboth, against every earlier versionany order; replay safe
NONEno checksnever on shared topics

4Enforcing It Before Deployment

A registry check at runtime is too late: the producer is already deployed when it tries to register an incompatible schema and starts failing. So the check moves into CI. Each schema change runs a compatibility test against the registry, which exposes an endpoint for testing a candidate schema against a subject, usually through a build plugin. If it fails, the pull request cannot merge. Registration then happens in the deployment pipeline, not from application code.

Properties
# Producer configuration in production
auto.register.schemas=false # applications never register schemas themselves
use.latest.version=true # serialize with the version registered by the pipeline
# Registry, set once per subject
PUT /config/orders.order-placed-value {"compatibility": "FULL_TRANSITIVE"}
# CI step on every pull request that touches schemas/
# test-compatibility schemas/orders/order_placed.proto against subject orders.order-placed-value
# -> is_compatible: false -> build fails with the reason

Turning off auto-registration in production is the key detail. Otherwise any producer built from an unreviewed branch could register a new version, and with a loose compatibility mode on its subject, break consumers. Exact property names vary between serializer libraries, so check your version.

5Evolution Rules Everyone Follows

The registry enforces compatibility mechanically, but humans still need to know which changes are allowed so they design correctly from the start. We document a short list. New fields are added as optional, with a sensible default meaning when absent. Fields are never renamed in a way that changes their identity, and their types never change; a field with a new meaning gets a new field. In Protobuf, field numbers are never reused: a removed field's number and name are marked reserved. Enum values are only added, with consumers prepared for unknown values. A truly breaking change gets a new topic, such as orders.order-placed.v2, with both topics running in parallel while consumers migrate.

Java
message OrderPlaced {
reserved 6; // was coupon_code; removed, number never reused
string order_id = 1;
google.protobuf.Timestamp placed_at = 2;
string currency = 3;
int64 amount_minor = 4; // cents: no floating point for money
repeated LineItem items = 5;
optional string sales_channel = 7; // added in v4: old consumers ignore it
}

6Ownership and Review

Shared schemas live in one repository, organised by domain, with a code owners file so that the producing team owns each schema and changes require review from it. Consuming teams can subscribe to the schemas they depend on and are added as reviewers for breaking-topic proposals. The repository generates and publishes libraries for each language from the schemas, so consumers get typed classes by updating a dependency instead of copying files. Each schema file includes documentation of field meanings and units. Together with the registry checks, this means a breaking change cannot reach production unnoticed, and a compatible change reaches every language automatically.

7Follow-up questions

Why not plain JSON without a registry?

Because nothing would stop a producer from renaming or retyping a field, and consumers in other languages would find out from failures in production. JSON Schema in the registry closes that gap if readability matters, but plain JSON leaves the contract in people's memory.

What happens to a consumer that sees a field it does not know?

With Protobuf, unknown fields are skipped by the parser and kept when re-serializing; with Avro, the reader's schema decides which fields it reads and others are ignored. That is what makes adding optional fields safe for old consumers.

How do we make a change that is genuinely breaking?

We create a new topic with the new schema and a new subject, have the producer write both for a migration period, move consumers one by one, and retire the old topic on a published date. Forcing a breaking change into an existing subject by relaxing its compatibility mode is not allowed.

8Conclusion

In this answer, we chose Protobuf with a schema registry as the default format for a multi-language Kafka platform, with JSON Schema allowed where readability matters, and set FULL_TRANSITIVE compatibility per subject for shared topics so old consumers read new data and new consumers replay old data. We enforced it in CI with compatibility tests and disabled auto-registration in production, documented the evolution rules, such as optional additions, reserved field numbers and new topics for breaking changes, and gave each schema an owning team in a reviewed shared repository.

What to say in the interviewAbout 90 seconds aloud

Open with

With dozens of teams in several languages, I would make the event format an enforced contract. Format: a schema-based one with a schema registry, and I would pick Protobuf as the company default because its code generation covers every language we use and many teams already know it from gRPC; Avro would be equally valid, especially for data-lake consumers.

Then, if they want more

For low-volume topics where people read messages, JSON Schema is allowed, registered in the same registry. Compatibility: on a shared topic the producer changes the schema and consumers upgrade on their own schedule, so old consumers must read new data, and new consumers replaying the topic must read all old data.

That means FULL_TRANSITIVE, set per subject in the registry; topics with one coordinated consumer can use BACKWARD_TRANSITIVE. Enforcement: every pull request that touches a schema runs a compatibility test against the registry and fails if incompatible, the deployment pipeline registers schemas, and producers run with auto-registration turned off in production.

Rules are written down: add only optional fields, never rename, retype or reuse a field number, mark removed numbers reserved, only add enum values, and use a new topic for real breaking changes.

Ownership: schemas live in one repository with code owners, the producing team owns each schema, consumers can review, and typed libraries are generated for every language from that repository.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your company publishes events on Kafka consumed by dozens of teams in several languages....": https://scrivio-interview-library.netlify.app/java/serialization/5e540e0fe4/