Menu

Protobuf: Why Google's Servers Don't Speak JSON
📰

Protobuf: Why Google's Servers Don't Speak JSON

DEV Community·Neural Download·7 months ago
#FwVBwFsx
Reading 0:00
15s threshold

https://www.youtube.com/watch?v=OsyKxWxGtiI

Your API returns a user. Three fields — an ID, a name, a bit for active. That exact payload, as compact JSON, is forty-one bytes on the wire. As protobuf, it's twelve. But compactness is the least interesting thing about protobuf. The real reason Google built it is something JSON fundamentally cannot do.

The JSON bill you pay on every request

Take this payload:

{ "id" : 12345 , "name" : "Alice" , "active" : true }

Enter fullscreen mode

Exit fullscreen mode

Twelve bytes of that are actual data. The other twenty-nine are JSON describing itself — quotes, colons, commas, and the key names id , name , and active spelled out in every single message. Every request. Every response. Forever.

You can compress it. You can minify it. It still has to spell itself out on the wire because every reader has to parse a self-describing document.

The real problem isn't bytes — it's fragility

A week later you add a field: email . You ship the new server.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.