JSON Performance
Sometimes when you do web service type things you have to pass around large data sets, and sometimes performance matters.
We have to interface with a bunch of different kinds of web services, so we use JSON+Rest, SOAP, XML-RPC, or whatever we need to to get the job done.
For a lot of internal communication I am a fan of a simple REST+JSON style solution. But, what do the performance numbers look like when faced with huge datasets? I recently started looking into making some asynchronous calls return faster to eliminate the delay between when a user submits a large change, and when they get feedback about it.
Fortunately, I found a place where Jim Washington does the numbers. Generally like simplejson for encoding, because it’s easy to extend, and at 9.5x slower than cjson, it fast enough for most cases.
But decoding with cjson is a different story, there’s nearly a 40x performance difference between cjson and simplejson. And you can tell it to fall back to simple-json whenever it throws a DecodeError, so the case for cjson with a simplejson fallback is pretty easy to make.
If we can drop the processing time on some of transactions, the response will be much closer to the request, and the user won’t feel the “asynchronicity” of things as much.