Sign In | Sign Up



performance

Optimize your Rails Code with Bullet Gem and Speed Up your site!

by Kevin

Why Bullet Gem?  For this Rails optimization, we'll focus on optimizing repeated SQL calls to retrieve objects associated with many relationships: N+1 queries problem. The solution to such an issue is an eager loading association.  Unoptimized N+1 affected code takes a significantly longer time as N times additional SQL calls are needed.  But, we should be careful when using that eager loading approach. This because unused eager loading can deteriorate our Rails app performance instead of improving it.  It's where the Bullet gem comes in handy. This gem will help us to find where the N+1 queries problem is happening. the eager loading associate is unused.   How to use Bullet Gem?  This depends on the current application's state. In our case, we do these: Add the bullet gem into Gemfile. Define a new Rails environment called optimization. Configure it to install the gem for that environment only Run the Rails app with that environment       1. Add the Bullet gem into Gemfile.      Here, we use its latest…
Score: 3.02
07/03/2020

Significantly Speed Up Showing Visits/Events of ahoy_matey gem by JSON Column Indexing in Rails

 
All of us want to visit a fast loading website. No one wants to wait for a slower website to load.  In the effort to speed up our website that is running Ruby on Rails, we decide to use the first-party analytics for Rails: ahoy_matey gem.  This article shows how to speed up showing the visitor/event counts of ahoy gem from 13 sec to 0.01 sec, more than 1,000 times faster!      Why we choose ahoy gem   It claims to be first-party analytics for Rails We'll have the server's side control. Any third-party analytics won't let us have this. It supports Rails 6 and its webpacker. It allows us to specify which pages on our Rails website to track. And the last one is it works with AMP.   However, the journey with ahoy_matey isn't a smooth one. Contrary to our belief, we notice the pages with ahoy_matey are much slower than those without it.  Something is wrong there.    InvestigationWe start our journey to investigate this problem. We begin with a page that's showing a list of articles. Every article there has a…
Score: 1.02
11/25/2020

Privacy settings changed!

Article is saved. Do you want to continue editing the article or leave and edit later?

Not logged in, Please login to continue

Location: United States (en)
  • United States (us)
  • 日本 (jp)
  • Indonesia (id)
  • India (in)
Terms and Conditions | Privacy Policy | About Us
FAQ | Contact Us
 
© 2025 123ish