3 ms·
Why would you make a comparison by gzipping one and not the other? Running gzip on the msgpack example reduced it from 304 to 248 bytes.
by dddbbb 7y ago
Why would you make a comparison by gzipping one and not the other? Running gzip on the msgpack example reduced it from 304 to 248 bytes.
- dwild 7y agoSure, but I think what he meant is that what the website is showing isn't the real gains. Without GZIP: JSON 583 bytes MessagePack 304 bytes 52 % With GZIP: JSON (GZIP) 289 bytes MessagePack (GZIP) 248 bytes 85%
- giantrobot 7y agoSo MessagePack lets you skip the CPU and memory usage needed to compress the JSON yet get similarly sized messages to compression JSON. The compression of the JSON Is a non-trivial extra load on a busy server.
- imtringued 7y agoOr you just use JSON with gzip and never think about this problem ever again. Choosing msgpack vs JSON is a micro optimization at this point. There are significantly better alternatives if you want to save CPU cycles.
- dwild 7y agoMost likely you'll have GZIP enabled on all your HTTP request. Your bandwidth will be a bottleneck way before GZIP CPU load become one. I just took a quick look and they do compress their queries, using Brotli, which is even more efficient than GZIP. They are behind Cloudflare, so it's probably from them. I just tried with https://jsonplaceholder.typicode.com/todos https://jsonplaceholder.typicode.com/todos and I get this: Raw: JSON: 24,311 MessagePack: 14,704 60 % With GZIP: JSON: 3,965 MessagePack: 4,063 102% With Brotli: JSON: 3,495 MessagePack: 3,704 106% So essentially, MessagePack compressed is WORSE than JSON, and not compressed, is at least 3 times worse than compressed.
- giantrobot 7y agoSo you're saying MessagePack with no compression is way smaller than JSON. Which means with no load for compression it has a 40% bandwidth savings. With compression it's negligibly worse than compressed JSON. Seems like a back foot argument for MessagePack over JSON. That's to say nothing of the encode/decode efficiency differences. In the case where your data can't be cached but CloudFlare proxies and compresses for you, MessagePack wins because your uncompressed connection to CF is 40% more bandwidth efficient so egress out of your app server for any traffic is reduced. In the case where CF can cache responses you get the same back end bandwidth win for a negligible (if any actual) amount of extra egress out of CF. Use what you want but if you need a schemaless serialization format, MessagePack works well and is compact for "free".
- kragen 7y agoA different way of looking at this is that MessagePack is a worse way to compress JSON than gzip or Brotli, at least under some circumstances.