Reading — step 1 of 5
Read
~1 min readFormat Basics
What MessagePack Is
MessagePack ("msgpack", invented 2008) is a binary format for the same data model as JSON: strings, numbers, booleans, null, arrays, maps.
Wire format goal: compact + fast. No schema needed.
JSON: {"name":"Alice","age":30,"active":true}
38 bytes
MsgPack: 83 a4 6e 61 6d 65 a5 41 6c 69 63 65 a3 61 67 65 1e a6 61 63 74 69 76 65 c3
25 bytes (~33% smaller)
vs JSON:
- Smaller: integers as binary (1-9 bytes vs decimal text); shorter strings.
- Faster: no string parsing for numbers; byte-oriented.
- Type-preserving: int vs float distinct, binary data native.
- No schema: like JSON, every message self-describing (vs Protobuf needing schema).
vs Protobuf:
- No schema: simpler, but no field renaming / evolution rules.
- Slightly less compact (Protobuf optimizes for known schemas).
- Faster setup: just install library; no code-gen.
Real systems:
- Redis MessagePack: optional binary format.
- Pinterest, Treasure Data, Fluentd: heavy users.
- WebSockets, RPC frameworks: where JSON is too verbose.
- MongoDB BSON is similar in spirit.
vs other schemaless binary:
- CBOR (RFC 8949): IETF-standardized similar format.
- BSON: MongoDB-flavored.
- Smile: Jackson's binary JSON.
- Ion (Amazon): binary + text formats.
We'll build a parser/encoder. Simple but covers all common types.
Reference: https://github.com/msgpack/msgpack/blob/master/spec.md
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…