Explain the classic ZooKeeper-era two-phase Kafka upgrade using inter.broker.protocol.version and log.message.format.version. Why must the binary upgrade and the protocol bump be separate steps?
answer
- Phase 1: new binaries, OLD protocol pinned
- Phase 2: raise IBP, then message format last
- mixed cluster => lowest-common protocol
- phase 1 is downgradable; format bump is the commit
- set IBP BEFORE the binary roll
basics
~20 sPhase 1: roll new binaries while pinning inter.broker.protocol.version (and log.message.format.version) to the OLD version, so new and old brokers still speak the old protocol. Phase 2: after all brokers are upgraded, roll again removing/raising the pins. Splitting it keeps a mixed-version cluster compatible and makes phase 1 downgradable.
solid answer
~50 sOn the old ZooKeeper-based brokers you set two configs. `inter.broker.protocol.version` (IBP) controls the wire protocol brokers use to talk to each other; `log.message.format.version` controls the on-disk record format. During an upgrade the cluster is temporarily mixed-version, so you cannot let a freshly-upgraded broker start speaking a newer inter-broker protocol that the not-yet-upgraded brokers cannot parse. So Phase 1: pin both configs to the current (old) version, then do a rolling restart swapping in the new binaries — every broker runs new code but still negotiates the old protocol and writes the old message format. The whole cluster is now on new binaries but behaviorally identical and fully downgradable. Phase 2: once all brokers are upgraded and stable, do a second rolling restart that raises `inter.broker.protocol.version` (and later `log.message.format.version`) to the new version, unlocking new features. Two phases decouple 'new code' from 'new behavior', so a mixed cluster is always speaking one agreed protocol.
go deeper
Know the headline: upgrade binaries first with the old protocol pinned, bump the protocol later.
Know both configs by name and the order, and that phase 1 is downgradable.
Explain the mixed-version compatibility reasoning, why the format bump is last/irreversible, and the pin-before-roll ordering.
Own the upgrade runbook including intermediate-IBP jumps, downgrade strategy, and migrating the mental model to KRaft metadata.version.
**The two version knobs (ZooKeeper-era brokers).** - **`inter.broker.protocol.version`** (IBP): the version of the protocol brokers use to communicate *with each other* (replication, controller/leader-election RPCs, etc.). A broker running new binaries can be told to keep speaking an *older* inter-broker protocol so it stays compatible with brokers that have not been upgraded yet. - **`log.message.format.version`**: the version of the record/message format written to disk and sent on the wire to clients. Bumping it can force a recompression/reformat of records and, critically, can break *old consumers* that don't understand the new format (and can disable the zero-copy optimization when down-converting for old clients). **Why a cluster goes mixed-version.** During a rolling upgrade you replace binaries one broker at a time, so for a window the cluster contains both old and new broker versions. They must keep replicating and electing leaders together. If a new broker immediately started using a newer inter-broker protocol, an old broker receiving those RPCs could fail to parse them — corrupting replication or controller traffic. **Phase 1 — upgrade binaries, hold the protocol.** Before touching binaries, explicitly set in `server.properties` on every broker: ``` inter.broker.protocol.version=<CURRENT_OLD_VERSION> log.message.format.version=<CURRENT_OLD_VERSION> ``` Then rolling-restart each broker onto the new binaries. Now all brokers run new code but negotiate the *old* protocol and write the *old* on-disk format. The cluster behaves exactly as before, and — crucially — you can still **downgrade** by rolling back binaries, because nothing newer was ever written or spoken. **Phase 2 — raise the protocol, then the format.** Once every broker is on the new binaries and healthy, do a second rolling restart that sets `inter.broker.protocol.version` to the new version. After that is stable across the cluster, you typically raise `log.message.format.version` last (often much later, or you skip pinning it on modern versions). Raising the message format is the riskiest/most irreversible step because it affects clients and on-disk data, so it is deliberately done last and separately. **Why separate steps (the core idea).** Two-phase decouples *deploying new code* from *enabling new behavior*. In any mixed-version moment the cluster has exactly one agreed inter-broker protocol — the lowest common denominator — so old and new brokers always understand each other. Phase 1 is fully reversible; only Phase 2 commits you. Doing it in one shot would mean a new broker could speak a protocol the old brokers can't, breaking replication during the window. **Edge cases and gotchas.** (1) **Always read the version-specific upgrade notes** — some jumps require an intermediate IBP. (2) Set the configs *before* the binary roll, not after, or a restarted new broker defaults to the newest IBP it supports. (3) On very modern Kafka, `log.message.format.version` is deprecated/ignored (message format v2 is universal), so the format step largely disappears, but the IBP discipline remains. (4) This whole IBP/message-format dance is the **KRaft predecessor**; under KRaft the equivalent is `metadata.version` managed by feature flags (separate topic).
- Why is log.message.format.version usually raised last and separately from inter.broker.protocol.version?It affects on-disk records and the format sent to clients; raising it can break old consumers and disable zero-copy down-conversion. It is the most irreversible change, so you do it after the protocol bump is proven stable — or skip it entirely on modern Kafka where format v2 is universal.
- If you set inter.broker.protocol.version AFTER rolling the new binaries instead of before, what can go wrong?A restarted new broker, with no pin, defaults to the newest IBP it supports and may send inter-broker RPCs that the still-old brokers cannot parse, breaking replication/controller traffic during the mixed window.
saying these in an interview costs you the question
- Saying you can bump inter.broker.protocol.version in the same rolling restart that swaps binaries.
- Claiming log.message.format.version controls inter-broker comms (it controls the record/client format).
- Believing the protocol bump is reversible the same way the binary upgrade is.
- Forgetting to set the IBP pin before upgrading binaries.