Slide 1

Slide 1 text

Application Monitoring for Ruby, Elixir, and Python Fast JSON API How fast is it really? Naohiro Takahashi [email protected]

Slide 2

Slide 2 text

How it looks like inside Scout

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Sample application summary Pandanese - Chinese language service

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Wrong!? (#1)

Slide 8

Slide 8 text

Target endpoint(template_cards#children) description - One of the busiest endpoint we have because it’s a public page -

Slide 9

Slide 9 text

Migrate to ActiveModelSerializer(AMS)

Slide 10

Slide 10 text

And worse! ActiveModelSerializer didn’t make it better(#2)

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Finally..., working with fast_jsonapi(#4)

Slide 13

Slide 13 text

Ugh...(#3) Fast JSONAPI won’t emit “simple” REST. Oh shit… it’s me, not Fast JSONAPI. Ref: https://jsonapi.org/format

Slide 14

Slide 14 text

json output comparison... Fast JSON API Our jbuilder and AMS output

Slide 15

Slide 15 text

How I measured performance? (#5) 1. Scout 2. Benchmark module from Ruby

Slide 16

Slide 16 text

Scout - Set up(#5-1)

Slide 17

Slide 17 text

Scout - Set up(#5-1)

Slide 18

Slide 18 text

Scout - first result (#5-1)

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Scout - (#5-1)

Slide 21

Slide 21 text

Benchmark - What to measure? (#5-2) - Serializable hash build ( Only fast_jsonapi vs AMS ) - json string output

Slide 22

Slide 22 text

Benchmark - Setup(Serializable hash build) (#5-2)

Slide 23

Slide 23 text

Benchmark - Serializable hash build - (#5-2) - Fast JSONAPI is faster(3.4x~5.8x) than AMS at any records number.

Slide 24

Slide 24 text

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...

Slide 25

Slide 25 text

Scout - Is jbuilder really slow? (#6)

Slide 26

Slide 26 text

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...