Your API is too slow!

Your API is too slow!

RedDotRubyConf 2016

Afa6e65b91b46f3317c3d3e94e9255f2?s=128

Grzegorz Witek

June 23, 2016
Tweet

Transcript

  1. @arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW!

  2. None
  3. @arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW!

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

  5. Grzegorz Witek

  6. is speed a feature?

  7. is lack of speed a bug?

  8. Algolia Github

  9. 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
  10. 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
  11. Long way of a request ! " #

  12. Latency ! " #

  13. Where are your users? "

  14. Where are your users? " Singapore Jakarta 13ms

  15. Where are your users? " Singapore Hanoi 100ms

  16. Where are your users? " Singapore New York 265ms

  17. Where are your users? " Singapore Shanghai 320ms

  18. Dynamic content acceleration ! CDN #

  19. Latency 

  20. Latency   

  21. Long way of a request ! " #

  22. Processing #

  23. Don’t be a smart-ass “Oh, I know, we have to

    cache it!”
  24. Measure gem 'ruby-prof'
 gem 'rack-mini-profiler'

  25. Measure in production mode pre-production stage

  26. Measure gem 'newrelic'
 gem 'skylight'

  27. Measure profile - focus on the slowest part

  28. Measure benchmark - compare alternative solutions

  29. Improve

  30. Improve Rely on your database

  31. Improve Where is your cache?

  32. Improve Redis on a separate machine - fast Redis on

    the same machine - faster Application memory - the fastest
  33. Improve Multi-layered cache (Russian doll caching)

  34. Improve When needed - mutate

  35. Improve Upgrade your libraries

  36. Improve When needed - replace your libraries

  37. Improve gem 'json'
 
 gem 'oj' gem 'oj-mimic-json'

  38. Improve Native extensions - not only C!

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

  40. Improve Move processing to the background

  41. Improve When desperate - extract part of the application

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

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

  44. Improve There's more, way more

  45. Long way of a request ! " #

  46. Download ! " #

  47. Improve Not only GZIP

  48. Long way of a request ! " #

  49. Speed up your API use CDN infrastructure profile and benchmark

    focus on the slowest part rewriting is the last thing to consider
  50. Speed up your API Ruby is fast enough Sinatra is

    fast enough Rails is fast enough
  51. @arnvald, RedDotRubyConf 2016 YOUR API IS TOO SLOW! 2TQDCDN[ HCUVGPQWIJ