Choice of FlatBuffers to replace JSON

Hi,

Yesterday I discovered that mediasoup is moving to FlatBuffers instead of JSON for its internal comms between the programming API and the worker executable.

This technical decision interests me a lot, and I would love to learn a bit more about this. So I’d like to ask you guys if there’s any writing I could read about the thought process behind the change. Once leaving the slow and bulky JSON, there are some obvious choices like FlatBuffers, but also others widely known like Cap’n Proto (such as used by Cloudflare). So this decision -as seen from outside- is not that clear-cut.

Kenton Varda -the author of Protobufs v2 and Cap’n Proto- has a popular post comparing these, but I’d love to know if you had some practical takeaways for mediasoup to tip the point in favor of one instead of another.

(or, you know, maybe all were just equally fit for the needs, and the choice was merely a matter of what’s the most popular! I’d imagine that’s a possibility too)

flatbuffers covers C++, Node and Rust and avoids memory copy when parsing. The decision was taken almost a year ago. If there were other choices we discarded them. If there are new ones it’s too late. It’s a year already working on this.

Oh I absolutely didn’t mean “you should have chosen something different” or anything like that!

I just meant “I would like to know if you compared them and learned something”. To also learn myself. If I had to choose a general purpose serialization format today, I would hesitate between flatbuffers and cap’n proto, so that’s why the question. They seem pretty on par, but there must be some difference.

Language support is definitely a strong reason, though. Regardless, I think any of those two would probably be a good enough choice anyway.

Existing alternatives were considered. flatbuffers was the best one by far.