The 30 second answer
I use a schema registry with a compatibility mode. Backward, the default, means new consumers can read old data, so consumers upgrade first. Forward means old consumers can read new data, so producers upgrade first. Full means both, and the transitive variants check against all past versions. Safe changes are adding optional fields with defaults. I never rename or reuse a field.
Use Schema Registry with a compatibility mode. The default is BACKWARD: new consumers can read old data, so upgrade consumers first. FORWARD means old consumers can read new data, so upgrade producers first. FULL means both. The _TRANSITIVE variants check against all past versions, not only the last. Safe changes are adding optional fields with defaults; never rename or reuse a field. Follow-up: Which mode when you can't control consumer upgrade timing? (FULL or FULL_TRANSITIVE.)
Alternate interview scenarios
"A deployment breaks communication between services. How do you handle versioning?"
This is the synchronous API version of the same contract problem, without a registry that enforces compatibility. I prefer additive changes: new optional fields, and never removing or renaming a field that consumers still read. Consumers must be tolerant readers that ignore unknown fields, which Jackson can be configured to do. For a breaking change, I run two API versions side by side, migrate consumers, and retire the old version only when its traffic is zero. Since Spring Framework 7 (Spring Boot 4), Spring MVC has built-in API versioning: it resolves the version from a header, query parameter, media type or path, and can send deprecation hints to clients. To catch breaks before deploy, I add consumer-driven contract tests such as Pact or Spring Cloud Contract to CI, and I use a canary rollout so a contract break reaches only a few requests.
Sources (5)
- Confluent: Schema evolution and compatibilitydocs.confluent.io
- Spring Framework reference: API versioning (Spring MVC)docs.spring.io
- Pact documentation (consumer-driven contract testing)docs.pact.io
- Spring Framework 7.0 release notes: API Versioninggithub.com
- Spring Boot 4.0 release notes: Spring Framework 7.0 and API Versioning auto-configurationgithub.com