All you need is Performance

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

All you need is Performance

This presentation is about how I used small techniques to improve speed of my rails application.

Sadiksha

April 13, 2016

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

16 slides
  1. All you need is Performance Sadiksha Gautam Software Developer @

    EnerNOC, Munich www.sadiksha.com @sadikshagautam (twitter) [email protected] 11/05/16
  2. Performance Issues ¡  Its all about users ¡  Blamed? ¡ 

    Happy? ¡  Temporary or permanent solutions 2
  3. Permanent Solutions ¡  Use your experience ¡  Avoid premature optimization

    ¡  Profiling ¡  Optimize server and client side performance 4
  4. Server and Client side ¡  Server side ¡  Upgrade Ruby

    ¡  Pagination ¡  Optimize database queries ¡  Client side ¡  Turbolinks ¡  Pjax 5
  5. Upgrade Ruby ¡  Rails Request Per Second ¡  Ruby 1.9.3

    ~ 86 rps ¡  Ruby 2.1.1 ~ 110 rps [Source: http://www.isrubyfastyet.com/] 6
  6. Upgrade Ruby ¡  Rails startup time ¡  Ruby 1.9.3 ~

    4.90 seconds ¡  Ruby 2.1.1 ~ 2.35 seconds [Source: http://www.isrubyfastyet.com/] 7
  7. Pagination ¡  Gem: will_paginate ¡  Limited data ¡  My application:

    ¡  450 data rows initially ¡  25 data after pagination ¡  Before: 5355ms ¡  After: 2488ms 8
  8. Profiling ¡  Gem – rack-mini-profiler ¡  Information about database queries

    [Source: http://railscasts.com/static/episodes/asciicasts/E368I01.png] 9
  9. Optimize Database Queries ¡  Add indexes – (gem lol_dba) ¡ 

    From 1.35s to 1.08s ¡  Use select and pluck ¡  Only required columns from database tables ¡  Pluck: array of data ¡  Includes and joins ¡  From 14,219 to 11,254 queries 10
  10. Turbolinks ¡  Built in for rails 4 ¡  For rails

    3: ¡  gem ‘turbolinks’ ¡  Speeds up application by two times ¡  Does not load all the unchanged assets 11
  11. Pjax ¡  Pjax = pushState + ajax ¡  Jquery plugin

    ¡  jquery_pjax (gem) ¡  Less automatic 12
  12. Further Improvements ¡  Browser caching ¡  Counter caching ¡  Bullet

    gem ¡  Performance testing (gem rails-perftest) 13
  13. References ¡  www.railscasts.com ¡  www.pluralsight.com ¡  https://github.com/plentz/lol_dba ¡  https://github.com/MiniProfiler/rack-mini-profiler ¡ 

    https://github.com/SamSaffron/flamegraph ¡  https://github.com/mislav/will_paginate ¡  https://github.com/rails/cache_digests ¡  http://railscasts.com/episodes/387-cachedigests?view=comments ¡  https://github.com/rails/jquery-rails ¡  https://github.com/kossnocorp/jquery.turbolinks ¡  https://github.com/defunkt/jquery-pjax ¡  https://github.com/flyerhzm/bullet 16

More Decks by Sadiksha

Other Decks in Programming