#Tech | 13 min read | Updated: 2/20/2023

Optimizing Performance of Rails Applications: A Practical Guide

Updated: 2/20/2023
13 min read

Did you know an app that loads in 1 second has a conversion rate 3x higher than a site that loads in 5 seconds? This goes to show application speed and performance are crucial for project success. Users expect the app to load as quickly as possible, and our main task is to meet their expectations. That is why it is important to carry out Rails performance tests regularly. 

Both experienced IT professionals and junior developers have tried to address the problem of Ruby on Rails framework optimization. Fortunately, we work with over 50 Ruby on Rails apps and can help decrease the time taken for apps to load. With our tips on how to improve Ruby on Rails app performance, your project will surely achieve success.

4 Things to Keep in Mind Before Starting to Optimize a Rails App

4 things to keep in mide before starting to optimize your rails app

Before we start with a detailed description of steps to take to optimize your RoR app, take a look at the following factors:

Performance Measurement

In 2011, almost half of all web users expected an app page to load in 3 seconds or faster. Internet connection has improved. Also, the time taken for pages to load has decreased over the years. These days, users expect an app to load in less than a second. This is what you need to be ready for.

Experts use various tools to monitor and improve website performance. We did that for one of our projects, Foody, a recipe marketplace. For example, to look for a solution for high-volume performance testing within a strict timeline, we engaged a performance testing specialist who made scripts for load testing the app to find out how many users the site could withstand. As a result, the Foody platform can simultaneously provide continuous access to 1 million users per hour.

Here are some other recommendations for performance measurement of your Rails framework app:

Web Page Test

Web Page Test provides general data about app performance based on numerous indicators. The results of the performance measurement session are clear, precise, and accessible. The tool is quite easy to use.

PageSpeed Insights

Have you ever used a Speed Score performance indicator? This is a Google tool used by PageSpeed Insights. The solution provides data about both web and desktop performance. Thus, it gives a complete picture of how the application will work in different environments. 

The most important thing is that Google considers the PageSpeed performance measurement results when ranking the web page. For example, the better performance your web app shows, the higher the rank on the search results page.

New Relic APM

New Relic APM will fit all of your needs. It is a great choice for Ruby applications and Java, Node.js, Python, and many other solutions. 

New Relic APM is a cloud-based system with a clear, intuitive interface that provides all the significant details concerning any application’s environment. For example, you can find the key metrics and ensure your app runs well. Additionally, New Relic APM may help solve other issues. It analyzes them in real time and shows ways to fix them.


Want to increase your RoR app performance

Contact us

Optimization of the Elements that Actually Need Optimization

Recently, one of our partners came to us with a particularly interesting case. He could not optimize a Ruby app. Every improvement he tried to make led to worse performance than the initial version demonstrated.

We analyzed the situation, measured important indicators, and compared the results. The conclusion was interesting. When working on Ruby app performance, apply essential changes only to elements that actually need them. So, spend more time identifying the weaknesses and focusing your effort on them and databases. There is not always a need to rewrite the app from scratch or try to optimize the whole solution.

Get Acquainted With Useful Gems and Plugins

Ruby performance optimization demands code cleaning and manual refactoring to save memory. Numerous third-party tools can help to get this routine job done quickly.

Specific Ruby gems and plugins provide great assistance with code optimization. For example:

  • Bullet gem helps to seamlessly address the N+1 problem, which will be discussed a little later. This gem is highly popular in the Ruby community and it works out of the box;
  • Yslow gem uses Yahoo! Rules for performance measurement and helps you identify problems.

How to Improve Ruby on Rails App Performance

After the introduction, it is time to take real steps toward your app’s success. Rails framework app optimization is a multicomponent task. Here are our tips on each component’s improvement.

Server Optimization

Server optimization of rails app

Everything from the memory capacity and the web hosting service to the quality of code delivered impacts a web app’s performance. For example, in our case, a few things helped our client’s property rental marketplace increase the web app performance and memory by 90%. One of the tasks for this platform was to optimize the page speed and server performance as much as possible since the load time affected customers’ bounce rate.

Our team improved the page and server performance by:

  • updating a server  
  • reducing and compressing images, which allowed them to load 3 seconds faster
  • optimizing back-end code

In this section, we will look at the methods to use for server optimization:

Increase RAM (Random Access Memory) Capacity

If the number of your app users increases and there is slight or considerable performance degradation, the very first thing to start checking is the server’s capabilities. 

Increasing Random Access Memory capacity will likely get your app back to top performance.

Another similar tip is to use a more powerful Central Processing Unit. It is the electronic machinery in the computer that carries out instructions from programs that allow a computer or other devices to perform its tasks.

Replace HDD With SSD

The upgrade to SSD (solid-state drive) is what you need to start using to amaze the users with the solution’s performance. This changes everything. Solid-state drives are much faster than the hard drives of the older generation, especially when there is a need to read and write data from different parts of them. The drives are the hardware where the user data is stored; thus, the speed of reading from them is a major contributing factor to the visible performance.

Use a Load Balancing Method

Modern high-traffic applications process hundreds of thousands of requests per second. The more requests that are processed, the harder it gets to respond immediately. 

Load balancing is a way to route requests to the server appropriately. It allows the app to attain maximum speed and skyrocket its performance.

With Veeqo, Sloboda Studio demonstrated the ability to solve the overload problem.

Due to the sharp increase in the number of customers, there was always a large number of invoices to process. To ensure that the servers are not overloaded, we chose to use AWS Lambda. It helps us generate and manage invoices without overloading the Veeqo servers.

Back-end Optimization

Backend optimization of rails app

After you have checked the basic things that may decrease the app’s speed or memory, it’s time to start with your Ruby code.

Keeping Your Code Clean

We do not want to reinvent the wheel by saying that clean code is your must-have. It is the axiom that every software engineer should always keep in mind. To succeed with clean techniques, here are some rules to remember:

  • Make the application logic beforehand;
  • Stick to a well-defined, clear structure;
  • Explain your actions with comments;
  • Keep the functions short;
  • Use standard naming principles.

It is important that your developers adhere to clean code principles and implement them to ensure that the apps run fast and seamlessly. Most Rails apps render something from the database onto the views, so it is good to optimize database calls first.

Work on N+1 Query Problems

It is way faster for one query to produce multiple results rather than producing them individually. Sometimes, your code does the latter. Each query brings one result, so it sends new ones repeatedly until the required results are obtained. Optimization is about making one single query produce hundreds of needed results. It has to span across all types of optimization.

The query-based issue is rather complex. That is why your developers need to be attentive and thoughtful about the code to ensure the queries are short, clear, and efficient.

Adding Indexes

One of the reasons for the delayed response is missing indexes. The more the tables expand, the slower the application gets. Each time a request appears, the database engine checks every cell until it finds the required information. All you need to do is add indexes to accelerate this process.

Keep in mind that indexes speed up the search but slow down the updates. Don’t underestimate the necessity of adding indexes to joint tables and foreign keys and to the models that represent polymorphic relations. Also, keep databases clean.

Use Background Job Processors

Background processes are something that may also impact your performance. Statistics calculations, report generation, video processing, and similar tasks may fall into this category. It can span across all other categories. Their automation is another step needed for better performance.

Optimizing background processes so as not to overload the web app is what we’ve battled with on one of our projects.

Creyos is a huge cognitive web app that has processed over 10 million tasks and keeps processing a large number of requests daily. The problem of potential system overload became crucial since such an overload could damage the platform. 

As for the solution, we had to make several processes – the web, background, and scheduled tasks. For web tasks, we use Amazon EC2, which is web-scale cloud computing development. There are different tasks on Amazon that we make: web, background, and scheduled tasks. The web tasks and background tasks with the common base are processed separately. Say, the user wants to download a lot of data on the web. What we do is transfer this request to the background tasks. This is how we avoid overload web applications. We’ve built the web application so that there are many independent parts. If one part stops working, others won’t collapse at the same time.

There are also many tools developed for the RoR framework specifically that may be useful for background processing and help the application load in less time. We prefer the following solutions:


Sidekiq is one of the most popular open-source gems experts use for background processing. It has a convenient dashboard for finding data about all the queues and response details.


Rescue is the alternative to Sidekiq, and devs use it to handle Ruby exceptions.

Active Job

The Active Job framework helps to deal with jobs in queues, too. It enables the parallel processing of small, well-organized units of background tasks.

Cache Everything You Can

Better speed means fewer meaningless actions. And this is where caching can help. It allows storing of content each time the server responds to a new request. There are several types of caching, each with its own specifics and purpose. You can take a look at them in the official Ruby documentation.

Another optimization you can do to increase view speed is to cache complex database queries. If your app shows stats and analytics, chances are that you are performing a complex database query to calculate each metric.

To use this solution to the best advantage, evaluate which part of the web application is damaging the performance and apply caching techniques to it.

Use Ruby GC Tuning

GC, or garbage collection, is one more concept you need to get acquainted with to optimize the Ruby on Rails app. This is a method of managing the app’s memory. Changing your Ruby GC settings can speed up both unit tests and, indeed, the whole application. Its algorithms are fascinating and require some extra research to be understood.

Frontend Optimization

Your application is not just made of brilliant Ruby code. To make it load in less time and run seamlessly, you also need to take care of its front-end.

Get Familiar With CDN

Distance thing that may hinder your endeavor from improving the performance of a Ruby on Rails app. The server may be a thousand miles away from the end user. The query-response time may take up to a minute. How do you deal with this?

A content delivery network (CDN) is your tool for content delivery optimization and improvement. A CDN is vital not only for rails framework apps but for any type of web application. It helps web content load fast, no matter where the end user is located.

When optimizing the Home Fit Out website, we came across a similar challenge. HOME FIT OUT is a digital platform that provides cutting-edge home furnishing solutions. 

Their images were not stored on the web app. Instead, they could be accessed via links that led to third-party servers line. Since only links were stored, images could drop out. This is because some furniture items were out-of-stock on a third-party server. Thus, images became inaccessible too.

Also, the images overloaded the system as they took up lots of space

To solve this problem, we uploaded all the images to AWS S3 and resized them. We also distributed the images via CloudFlare CDN. It is Amazon’s content delivery network that speeds up load time. 

Now the images are not dragged directly from the server. Instead, they are stored in the CDN, and users access the nearest local server from where the image has been dragged.

Share Static Files

Normally, you don’t need to generate files on the go. In the case of CSS files and images, you never have to do this at all. Using static files, you save your time for something more important and boost the app’s response speed.

Compress the Files

With attractive images, it is possible to get more and more users to visit your website or web app. These images are breathtaking, lovely, and authentic, but they increase the web page’s loading time. Compress the files you design to appeal to your users with both great images and lightning-fast page load.

Make Friends With AJAX

Influenced by the most popular programming language, the AJAX technique was created to find applications in a variety of fields. Actually, it is a whole set of techniques for asynchronous solutions development. It makes web page content change dynamically. There is no need to reload a page every time you want to check the update; it is all automated. AJAX minimizes the number of queries and, thus, helps to improve performance.

Do you want to optimize your Rails app?

Contact Us

Our Experience

We’ve worked with apps that needed rails optimization, and here are some of the examples:

Fortune Wheel HR

Fortune Wheel HR Homepage

Fortune Wheel HR is a SaaS-based app that has created a gamified reward system for various companies that want to diversify everyday corporate life and individual users who would like to participate in quizzes and receive valuable prizes.

Goal: The client came to Sloboda Studio with the goal of application optimization and the creation of new features for the mobile app.

As a result of our cooperation, the company upgraded its mobile platform to two types of modes: for work and fun. Due to memory optimization, the application downloads twice as fast as before. This is because our team optimized the images and compressed all data, ensuring not lose any quality needed to upload the application to stores. Saving lots of memory for other heavy tasks

Also, to further increase productivity, our team switched from monolithic Ruby to microservice Java. This created a better workflow and a more flexible application architecture.

In Conclusion

Launching excellent solutions is not like riding a bike. Creating a legendary application requires your full dedication and maximum effort. We have discussed how to improve Ruby on Rails app performance, and your road to success includes:

  • Server optimization:
    • Increasing Random Access Memory capacity
    • Replacing HDD with SSD
    • Using a load-balancing method
  • Back-end optimization:
    • Keeping your code clean
    • Work on query problems
    • Adding indexes
    • Using background job processors
    • Caching database and more
    • Using Ruby GC Tuning
    • Ensuring the database has enough memory
  • Frontend optimization:
    • Using a CDN
    • Sharing static files
    • Compressing the files
    • Using AJAX

Clean up your database queries, then create AJAX requests wherever you can, and finally, cache as many views as possible. You can move on to WebSockets and database caching after that.

We hope our tips will help take your RoR framework application performance to the next level. Sloboda Studio has successfully optimized numerous platforms like Veeqo, Foody, Fortune Wheel HR, and Home Fit Out. If you need help with your project, contact our team for a professional consultation.

Frequently Asked Questions

How do you optimize the system performance in Rails?

There are three main ways to optimize your system’s performance in Rails – Server, Back-end, and Frontend optimization:

Server optimization:

  • Increasing Random Access Memory capacity
  • Replacing HDD with SSD
  • Using a load-balancing method

Back-end optimization:

  • Keeping your code clean,
  • Work on query problems,
  • Adding indexes,
  • Using background job processors,
  • Caching,
  • Using Ruby GC Tuning

Frontend optimization:

  • Using a CDN,
  • Sharing static files,
  • Compressing the files,
  • Using AJAX

What may be the reason why my Ruby on Rails application is slow?

There are a plethora of reasons why your ruby on rails application may be slow. Usually, it is a combination of these factors that decrease the speed and performance of the app significantly. For example:

  • Increase in the number of users,
  • Low RAM (Random Access Memory) capacity,
  • Poorly written code,
  • Query issues,
  • Missing indices,
  • Presence of large images, line, etc

Fixing all of these issues will help increase the speed and performance of your Rails app.

Is Ruby on Rails still relevant in 2023?

Ruby on Rails is still relevant in 2023 and will remain so for many more years to come. It is a simple and powerful platform to quickly make rapid prototypes, MVPs, and any kind of web application.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.


Notify of

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Recommended articles
#Tech 6 min

Do you love Christmas gifts? Just wait for the 2020 winter holidays! 2020 will be a big year for the whole Ruby community. The Ruby founders have a really great present in store for us…

#Tech 10 min

In 2022 almost every person uses video conferencing services for different reasons. And I bet that you can’t already imagine life without video communication using a peer-to-peer video conference. Could you know that it’s been…

#Tech 11 min

No matter what business you are running, it does not really exist if it has no manifestation on World Wide Web. However, having a website is not the end of the story . It must…

Scale your team with us

Drive your business with our dedicated developers

    *By submitting this form, you agree to our Terms of Use and Privacy Policy.

    Alex, VP of Client Engagement