Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fast JSON API - How fast is it really?

naohiro-t
February 06, 2019

Fast JSON API - How fast is it really?

At Tokyo Rubyist meetup on Feb 6th, 2019.

naohiro-t

February 06, 2019
Tweet

More Decks by naohiro-t

Other Decks in Programming

Transcript

  1. Agenda 1. What I know about REST API… 2. How

    we found the problem 3. My journey to end up with Fast JSON API 4. Benchmark Results
  2. Everything I know about REST API Use jbuilder to return

    json format data… /template_cards/896c-e11f833...json views/template_cards/index.json.jbuilder views/template_cards/_template_card_only_frontindex.json.jbuilder
  3. What is Fast JSONAPI? - Created by - A lightning

    fast JSON:API serializer for Ruby Objects. - Serialization time is at least 25 times faster than Active Model Serializers on up to current benchmark of 1000 records - Why fast? Ref: https://medium.com/netflix-techblog/fast-json-api-serialization-with-ruby-on-rails-7c06578ad17f
  4. Ugh...(#3) Fast JSONAPI won’t emit “simple” REST. Oh shit… it’s

    me, not Fast JSONAPI. Ref: https://jsonapi.org/format
  5. Scout - Problem on first setup (#5-1) - Couldn’t see

    much performance improvement ➢ Requested some template_cards which has less children, so response time is not that slow...and hard to tell performance difference - json output format was not same across serializers ➢ Follow JSON:API format - There are some easy ways to improve AMS and jbuilder… ➢ Use Oj as json parser for AMS and jbuilder - Send too many requests to the app at the same time, so taking more time on Middleware layer ➢ Less concurrency on sidekiq
  6. Benchmark - What to measure? (#5-2) - Serializable hash build

    ( Only fast_jsonapi vs AMS ) - json string output
  7. Benchmark - Serializable hash build - (#5-2) - Fast JSONAPI

    is faster(3.4x~5.8x) than AMS at any records number.
  8. Benchmark - json string output - ...? (#5-2) - Fast

    JSONAPI is faster(4.0x~4.8x) than AMS at any records number. - Jbuilder is as fast as fast_jsonapi...
  9. Conclusion - Advantage and Disadvantage of fast_jsonapi ➢ Faster. ➢

    JSON:API format Depends on the data size you response. If it’s small, it may not worth to migrate - What did I actually done with Pandanese? ➢ We decided to migrate to fast_jsonapi for some endpoints that return large json - Was it really the solution for the problem I was having? ➢ No...