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

Tips and Tricks to make RubyonRails webpage response Faster

Tips and Tricks to make RubyonRails webpage response Faster

Parameters, Lib Gems and references take can help improve rails performance other than database and architecture tweeks

Pritesh Jain

October 26, 2013
Tweet

More Decks by Pritesh Jain

Other Decks in Programming

Transcript

  1. ruby gc params  RUBY_HEAP_MIN_SLOTS • Initial number of heap

    slots. It also represents the minimum number of slots, at all times (default: 10000)  RUBY_HEAP_SLOTS_INCREMENT • The number of new slots to allocate when all initial slots are used (default: 10000)
  2. ruby gc params  RUBY_GC_MALLOC_LIMIT • The number of C

    data structures that can be allocated before triggering the garbage collector. This one is very important since the default value makes the GC run when there are still empty heap slots because Rails allocates and deallocates a lot of data (default: 8000000)
  3. What is a heap slot value  sizeof(RVALUE) is 

    20 if 32-bit, double is 4-byte aligned  24 if 32-bit, double is 8-byte aligned  40 if 64-bit  Rvalue( Ruby Value) are strutures contains some data and the same set of flags.  RValue structures in arrays called
  4. ruby gc params  Ref:-  http://meta.discourse.org/t/tuning-ruby-and-rails-f or-discourse/4126 https://gist.github.com/burke/1688857 

     http://snaprails.tumblr.com/post/241746095/rubys -gc-configuration   http://blog.evanweaver.com/2009/04/09/ruby-gc-t uning/  http://www.mikeperham.com/2009/05/25/memory-
  5. rake mini profiler  Profiling Requests  Ref:-  https://github.com/MiniProfiler/rack-min

    i-profiler • • http://samsaffron.com/archive/2013/0 3/19/flame-graphs-in-ruby-miniprofiler • http://confreaks.com/videos/2668-gog aruco2013-measuring-ruby
  6. rake mini profiler  Profiling Requests  Ref:-  https://github.com/MiniProfiler/rack-min

    i-profiler • • http://samsaffron.com/archive/2013/0 3/19/flame-graphs-in-ruby-miniprofiler • http://confreaks.com/videos/2668-gog aruco2013-measuring-ruby
  7. Optimize Images  save images dim  Optimize images before

    saving jpeg optim  Ref: -  https://github.com/janfoeh/paperclip-opti mizer • • http://www.ror-e.com/posts/6-optimize-yo ur-images • • paperclip-public gem
  8. Caching objects Identitycache  Ref:- • http://www.shopify.com/technology/7 617983-identitycache-improving-perf ormance-one-cached-model-at-a-time# axzz2hDcpvbCw

    • NOT TRIED • https://github.com/linhchauatl/object_ca cheable • http://railscasts.com/episodes/115-mod el-caching-revised?view=comments •
  9. Counter cache columns Adding a counter cache to a has_many/belongs_to

    ActiveRecord relationship  Ref:- • http://www.shopify.com/technology/7617983-identitycache-impro ving-performance-one-cached-model-at-a-time#axzz2hDcpvbCw • NOT TRIED • https://github.com/linhchauatl/object_cacheable • http://railscasts.com/episodes/115-model-caching-revised?view= comments •
  10. Eager Loading  Eager Loading ref table objects Ref:- •

    http://railscasts.com/episodes/22-eage r-loading • bullet gem • http://railscasts.com/episodes/372-bul let
  11. assets optimisation  config.action_controller.asset_host = “static.example.com”  pagespeed  Ref:

    - • https://github.com/rumblelabs/as set_sync • S3 + Cloudfront CDN •
  12. Full Text Search index  Full Text Search Indexing other

    than Database columns which are frequent joined and searched http://pat.github.io/thinking-sphinx/   http://sphinxsearch.com/about/sph inx/
  13. gem name ,require: false  group:development do  gem "foreman“

    , require: false  end  group:production do  gem "thin", require: false end  Set false to all