How to improve your ruby on rails app speed ??
Link :: https://www.bacancytechnology.com/blog/ruby-on-rails-performance-tuning
Link :: https://thecodest.co/blog/ways-to-increase-your-rails-performance/
....................................................................................................
1. optimize your ruby code
2. indexing
3. make use of gems and plugins
4. cache data
5. backend optimization ::
6. keep your code clean :
....................................................................................................
....................................................................................................
- Create the app logic beforehand;
- Stick to well-defined clear code structure;
- Explain your actions with comments;
- Keep the functions short;
- Follow standard naming principles.
....................................................................................................
How to increase Rails App performance ::
1. avoid creating unnecessary objects
2. read files line by line
3. avoid method iterations on larger collections
4. Use String::<< method
5. let's talk rails
6. eager loading on N+1 query problem
7. call only what you need
8. render partials properly
9. write less code use more gems
10. use backgroung processing :: sidekiq
....................................................................................................
1. reduce size of images and tables
2. reduce garbage collector call amounts
3. minimize the no of database requests
4. correctly indexing the database
5. use bullet gem
6. minimise the use of certain methods
7. select the right session storage
....................................................................................................
Very important Link ::
https://www.mskog.com/posts/42-performance-tips-for-ruby-on-rails
https://applikeysolutions.com/blog/10-tips-to-speed-up-your-ruby-on-rails-app
description of the link ::
1. Select the Right Session Storage
2. Use the Bullet Gem
3. Turn Caching On
4. Minimize the use of Certian Methods
5. Correctly Index the Database
6. Turn Caching On
7. Use the bullet Gem
8. Determine your application's current level of performance
....................................................................................................
....................................................................................................
From first to last -- main issues to optimize the performance ::
1. Eliminate N+1 Queries ::
You can use Bullet Gem to automatically eliminate the N+1 query problem or rack-mini-profiler but , bullet gem is better OR you can eliminate it by using the includes in queires.
2. Eager or Preloaded Queries ::
You should always use the includes to improve the performance of relationships in the Active-Record ,
atleast one least extra query is always there , you can avoid this by the eager_load which will make a signle query instead this is not always faster but it can lead to significant memory usage.
3. Use proper indexes for full text search ::
if you use the simple search then the perforamcne of the website isvery slow so you can use the gems - like searchkick gem or pg-search gem or elastic-search gem
4. beware of pagination ::
pagination can be a huge problem if you are using the group query , you can use the faster pagy-gem (is much faster than other solutions ).
5. Try jruby ::
jruby is the java implementation of jruby which is faster
6. Asynchronous partial rendering :: render_async gem use for the partial rendering , view renedering in rails can take lot of request time .
7. Linking - perfect links ::
when the next page is loaded in the background it takes some time , so you can load the next page using ajax which is instantaneous . instaclick,quicklink,turbolinks with instaclick we can use for the linking.
8. Use a cdn for your assets :: Assets(javascript, css , images) can easily be cached by the fingerprinting in rails , you can use bunnycdn for this.
9. Reduce Garbage Collector Call Ammounts :: Each time garbage collector is launches the perfomrance of the app is suspended for 100-400 ms .
10. Reduce size of Images and tables ::
11. Minimize the number of Database Requests ::
Do not overuse the database connection
12. Minimise the use of Certain methods :: Some methods in ruby consumes a lot of resources like - find_by and find_by_all , so opting out these two methods .
13.
Comments
Post a Comment