News for hackers. Stuff that matters.
Re:Oj – Optimized JSON in Ruby by pmontra on Tuesday April 25, 2017 @10:04AM (#14193580)
I remember a Rails application I developed a couple of years ago. Basically a JS dashboard over a time series database, but not a SPA. Let's say a few JS-fat pages displaying graphs with filters. The JS code in the pages made API calls to the Rails controllers which answer in JSON. Plus, we had some cron jobs pulling JSON data from a remote API.

The application was fast enough but the data transfer started to dominate response time when the queries were large. We did several optimizations to reduce the size of the JSON (gzip among them, obviously) and sometimes building the JSON manually instead of using the jbuilder provided a speedup.

The cron jobs were OK. Using oj made a noticeable difference over the default parser. Batch inserts in the db made a big difference too (the activerecord-import gem). With those optimizations there was no need to write everything else in a more performant language. After all, oj and batch inserts already moved most of our performance critical code from Ruby to C.

There are no comments on this comment yet.