3 ms·
JSON will easily dominate CPU usage in any modern application that uses it for its API (and is not itself something intrinsically CPU-hungry like crypto or mach
by lobster_johnson 9y ago
JSON will easily dominate CPU usage in any modern application that uses it for its API (and is not itself something intrinsically CPU-hungry like crypto or machine learning).
We benchmarked one of our apps, written in Go, which uses JSON extensively both for the API and for internal storage, and we found that around 90% of the CPU time is spent serializing and deserializing JSON.
The JSON code itself is a tiny portion of any app, so it's one of those rare optimization cases where a small change can yield significant speed-ups for the entire app.
- always_good 9y agoWas it a JSON echo server?
- foobarbazetc 9y agoOur Scala based servers handling thousands of RPS only deal with JSON via Jackson and JSON encode/decode doesn’t even register in profiles.
- megous 9y agoDepends on the way you handle JSON. You don't need to deserialize the entire received JSON string and then walk the node tree, you can walk the string as is. With this, you can process 500MB/s or more of JSON on a single core. On the other side, you can produce JSON string directly, saving the need to produce some intermediate representation in memory. You should be able to saturate 10gbit line on a multicore server easilly with this approach.
- akvadrako 9y agoAgreed; in data-centric apps the JSON parsing time is a major time suck. But sometimes it can be heavily optimised with a good library, like fastjson for Java.