Slide 1

Slide 1 text

@arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW!

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

@arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW!

Slide 4

Slide 4 text

@arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW! 2TQDCDN[ HCUVGPQWIJ

Slide 5

Slide 5 text

Grzegorz Witek

Slide 6

Slide 6 text

is speed a feature?

Slide 7

Slide 7 text

is lack of speed a bug?

Slide 8

Slide 8 text

Algolia Github

Slide 9

Slide 9 text

Web application optimization loading priority static content dynamic content domain sharing JavaScript compression asset minifying CSS HTML un-CSS prefetching HTTP/2 image sprites CDN database optimization multi-threading

Slide 10

Slide 10 text

Web API optimization loading priority static content dynamic content domain sharing JavaScript compression asset minifying CSS HTML un-CSS prefetching HTTP/2 image sprites CDN database optimization multi-threading

Slide 11

Slide 11 text

Long way of a request ! " #

Slide 12

Slide 12 text

Latency ! " #

Slide 13

Slide 13 text

Where are your users? "

Slide 14

Slide 14 text

Where are your users? " Singapore Jakarta 13ms

Slide 15

Slide 15 text

Where are your users? " Singapore Hanoi 100ms

Slide 16

Slide 16 text

Where are your users? " Singapore New York 265ms

Slide 17

Slide 17 text

Where are your users? " Singapore Shanghai 320ms

Slide 18

Slide 18 text

Dynamic content acceleration ! CDN #

Slide 19

Slide 19 text

Latency 

Slide 20

Slide 20 text

Latency   

Slide 21

Slide 21 text

Long way of a request ! " #

Slide 22

Slide 22 text

Processing #

Slide 23

Slide 23 text

Don’t be a smart-ass “Oh, I know, we have to cache it!”

Slide 24

Slide 24 text

Measure gem 'ruby-prof'
 gem 'rack-mini-profiler'

Slide 25

Slide 25 text

Measure in production mode pre-production stage

Slide 26

Slide 26 text

Measure gem 'newrelic'
 gem 'skylight'

Slide 27

Slide 27 text

Measure profile - focus on the slowest part

Slide 28

Slide 28 text

Measure benchmark - compare alternative solutions

Slide 29

Slide 29 text

Improve

Slide 30

Slide 30 text

Improve Rely on your database

Slide 31

Slide 31 text

Improve Where is your cache?

Slide 32

Slide 32 text

Improve Redis on a separate machine - fast Redis on the same machine - faster Application memory - the fastest

Slide 33

Slide 33 text

Improve Multi-layered cache (Russian doll caching)

Slide 34

Slide 34 text

Improve When needed - mutate

Slide 35

Slide 35 text

Improve Upgrade your libraries

Slide 36

Slide 36 text

Improve When needed - replace your libraries

Slide 37

Slide 37 text

Improve gem 'json'
 
 gem 'oj' gem 'oj-mimic-json'

Slide 38

Slide 38 text

Improve Native extensions - not only C!

Slide 39

Slide 39 text

Improve https://github.com/rustbridge/helix https://github.com/d-unseductable/ruru

Slide 40

Slide 40 text

Improve Move processing to the background

Slide 41

Slide 41 text

Improve When desperate - extract part of the application

Slide 42

Slide 42 text

Improve I said "when desperate" not "ASAP NOW!!!11"

Slide 43

Slide 43 text

Improve I said "part", not "rewrite everything in Go"

Slide 44

Slide 44 text

Improve There's more, way more

Slide 45

Slide 45 text

Long way of a request ! " #

Slide 46

Slide 46 text

Download ! " #

Slide 47

Slide 47 text

Improve Not only GZIP

Slide 48

Slide 48 text

Long way of a request ! " #

Slide 49

Slide 49 text

Speed up your API use CDN infrastructure profile and benchmark focus on the slowest part rewriting is the last thing to consider

Slide 50

Slide 50 text

Speed up your API Ruby is fast enough Sinatra is fast enough Rails is fast enough

Slide 51

Slide 51 text

@arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW! 2TQDCDN[ HCUVGPQWIJ