We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Api Design Protocols
Free preview: the first 2 parts of this 6-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Api Design Protocols
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Protobuf and Avro require schemas. Thrift requires an IDL. What if you want binary efficiency without defining schemas? What if you want a drop-in replacement for JSON that is just smaller and faster?
That is MessagePack. It serializes the same data structures as JSON (objects, arrays, strings, numbers, booleans, null) in a compact binary format. No schema required. No code generation. You can literally swap JSON.stringify for msgpack.encode and get 20-50% smaller payloads with 2-5x faster serialization.
MessagePack is used by (as RESP3's binary payload format), Fluentd (log shipping between servers), SignalR (ASP.NET real-time hub protocol), and many gaming backends where JSON's overhead matters but Protobuf's complexity is not justified. The Unity game engine supports MessagePack natively for network serialization in multiplayer games.
Sadayuki Furuhashi created MessagePack in 2008 at Treasure Data (now part of Arm). The design goal was simple: same semantics as JSON, fewer bytes. No new type system, no schema, no compilation step. Just binary JSON.
// JSON
const json = JSON.stringify({ name: "Roni", age: 30, active: true });
// '{"name":"Roni","age":30,"active":true}' 39 bytes
// MessagePack
const msgpack = encode({ name: "Roni", age: 30, active: true });
// Binary 23 bytes (41% smaller)
How MessagePack saves space:
The encoding in detail:
JSON: { " n a m e " : " R o n i ", " a g e " : 3 0, ...}
7B 22 6E 61 6D 65 22 3A 22 52 6F 6E 69 22 2C ...
39 bytes of ASCII text
MsgPack: 83 A4 6E61 6D65 A4 526F 6E69 A3 616765 1E C3
83 = fixmap with 3 entries (1 byte)
A4 = fixstr of 4 bytes (1 byte)
6E616D65 = "name" (4 bytes)
A4 = fixstr of 4 bytes (1 byte)
526F6E69 = "Roni" (4 bytes)
A3 = fixstr of 3 bytes (1 byte)
616765 = "age" (3 bytes)
1E = positive fixint 30 (1 byte!)
C3 = true (1 byte!)
Total: 23 bytes
The integer 30 costs 2 bytes in JSON ("30" as text) but only 1 byte in MessagePack (0x1E, direct binary). The boolean true costs 4 bytes in JSON but 1 byte in MessagePack. These savings compound at scale.