5 ms·
I used to think binary formats for network protocols were a really good idea until I found out how big the TCP header itself can be. Saving a few bytes from yo
by udp 8y ago
I used to think binary formats for network protocols were a really good idea until I found out how big the TCP header itself can be. Saving a few bytes from your payload by using binary representations of integers doesn't make a huge difference when the TCP header is 60 bytes.
- dmm 8y agoJust to add another dimension to your analysis, if you're sending large binaries the 33% overhead of Base64 adds up pretty quickly. It may not apply to your use case but if you are delivering images or video over a websocket it can make a big difference.
- dchest 8y agoOn the other hand, gzip can reclaim most of those 33% with Huffman encoding.
- dmm 8y agoThat's something I hadn't considered. I'll have to do some benchmarking. Thanks!
- Const-me 8y agoOnly in some cases. Also it increases latency. Here’s my old article about Microsoft’s binary XML format: http://const.me/articles/net-tcp/ http://const.me/articles/net-tcp/ As you see, for some payloads it compresses XML to 9% of the original size. The data contract serializer included in .NET framework (and even in .NET Core) can read & write objects directly from/to this binary serialization format, without intermediate text XML anywhere.