Part 11 of 11
Looking back
The choice of encoding affects more than speed. It shapes your architecture and how easily you can change your app.
Rolling upgrades are a big win for evolvability:
- You release new versions without downtime.
- That encourages frequent, small releases instead of rare, big ones.
- Deploys get less risky, because you spot a bad release early and roll it back before it hurts many users.
To make them work, assume different machines run different versions of your code, and make all data both backward and forward compatible.
| Kind of format | Strengths | Weaknesses |
|---|---|---|
| Language-specific | Easy to use | One language only, weak compatibility, security risk |
| Text (JSON, XML, CSV) | Used everywhere | Compatibility depends on how you use them; schemas optional; vague about numbers and binary data |
| Binary with schema (protobuf, Avro) | Compact, clear compatibility rules, schemas as docs, generated code | Not readable by people until decoded |
| Dataflow mode | Who encodes | Who decodes |
|---|---|---|
| Database | The writer | The reader |
| REST or RPC | The client encodes the request; the server encodes the response | The server decodes the request; the client decodes the response |
| Events and messages | The sender | The receiver |
Key takeaways
- Old and new code and data always overlap, so plan for backward compatibility (new reads old) and forward compatibility (old reads new).
- Old code must keep fields it does not understand, or a read-change-write cycle loses data.
- Built-in language serializers are for short-lived data only; JSON, XML, and CSV are everywhere but vague about numbers and binary data.
- Protobuf replaces field names with tags: never change or reuse a tag, and add new fields with new tags.
- Avro stores bare values, needs the writer's schema, and only adds or removes fields that have defaults.
- Schemas give compact data, documentation that stays true, compatibility checks, and type-checked code.
- Data outlives code, so databases mix many schema versions and migrate lazily.
- A network call is not a local call: plan for lost replies, timeouts, retries, and idempotence, whether you use RPC, workflows, or message brokers.