Video in progress

Strong Middle 🧩 Microservices

In Avro and Schema Registry, what do the BACKWARD and FORWARD compatibility modes mean, and how do they affect deploy order?

BACKWARD means the new schema can read old messages, so consumers are upgraded first. FORWARD means the old schema can read new messages, so the producer is upgraded first. FULL requires both.

📖 Answer

In Kafka, messages are kept for a long time, and the producer and consumer are deployed at different times. When you register each new schema version, Schema Registry checks it against the compatibility rule and rejects it if it is violated.

BACKWARD (the default in Confluent):

  • you can add a field with a default value;
  • you can delete a field;
  • you can't add a required field with no default, because old messages don't have it. Order: you move the consumers to the new schema, then the producer.

FORWARD:

  • you can add a field (the old consumer ignores it);
  • you can delete only a field that has a default. Order: the producer first.
{"name": "discount", "type": ["null", "long"], "default": null}

Adding a "nullable + default" field like this is safe in both directions, which is why many teams pick FULL mode and don't think about deploy order.

One more subtle difference: BACKWARD compares only with the latest version, while BACKWARD_TRANSITIVE compares with all previous versions. If a topic holds messages from half a year back and a consumer may re-read them from the beginning, you need transitive.

Renaming a field is "delete + add" in every mode. Avro has aliases, but test it on both sides before relying on it.