How does Kafka support schema evolution?
Instruction: Discuss the strategies Kafka provides for managing schema changes in data without breaking downstream consumers.
Updated
Official answer
Kafka brokers store record keys and values as bytes; Apache Kafka does not automatically validate application schemas or include a mandatory schema registry. Producers and consumers need a shared serialization contract. A separately deployed registry can version schemas and enforce compatibility rules during registration.
Define compatibility in the reader/writer direction. Backward compatibility means a new reader can read older data; forward compatibility means an old reader can read newer data; full compatibility requires both. A non-transitive registry mode may check only the previous version, while a transitive mode checks the configured history. Retained records and replay determine how much history matters.
For Avro, adding a field to the new reader with a suitable default lets that reader supply the value when reading old records lacking the field. That is the backward-compatible direction. An old reader ignores a new writer's extra field; the new field's default is not what makes that direction work. Arbitrary type changes, missing required fields or different record identities can still fail.
Choose a rollout order and test real serialized writer/reader pairs, including replay, tombstones and key schemas. Preserve writer-schema identifiers and availability. Structural compatibility does not establish unchanged business meaning: changing an amount from dollars to cents can decode successfully and still be wrong. Coordinate semantic changes, document units and version an incompatible contract deliberately.