Ruby on Rails scalability – which is the biggest issue?

Marlena Walburg

When you think about the greatest advantages of any technology or framework, scalability will probably come to your mind. Well, this is an important feature needed in the context of further development. If you want to extend your application with new features, you need to consider whether it enables scaling before choosing the technology. Certainly, the type of project will also play a role here. When focusing solely on Ruby on Rails, which, as we recently stated, is not dying at all, we need to consider various factors. RoR is a server-side web application framework, written in Ruby. It is based on the model-view-controller design pattern, providing the default database, web service, and website structure. RoR emphasizes the use of other well-known software engineering patterns and paradigms, including the convention over configuration, don’t repeat yourself, and the active record pattern. As a framework primarily for web application development, its use cases cover all kinds of websites or online platforms. The list of examples of what can be built in Rails is long, mainly due to the huge, still evolving number of gems and libraries that are a kind of building blocks for different types of applications. Can we scale Ruby on Rails applications then?

Is Ruby on Rails scalable?

In the case of Ruby on Rails scalability, it should be first discussed what scalability itself is. This term refers to the potential of an application built on a given technology to develop and manage more user requests per minute (RPM) in the future. It is a long process that concerns almost every element of the system, both in terms of hardware and software. Talking about the scalability of technology is quite commonplace because it is not technology that has to or can scale, but rather the architecture of the entire system. Scaling an application is not an easy process. Before you start planning how and when to scale your app, you should understand it well. Thus, the ability of an application to process multiple user requests simultaneously may prove insufficient over time. Such an initial structure of the server part of the application cannot maintain stable performance without some disruptions, so we want to scale it. The architecture on which it is based is responsible for software transformation. It is therefore essential to consider whether the selected architecture has the necessary scaling tools, what the desired number of users the application should be able to process per minute, which environment to choose at the beginning of creating a web application, etc. Ruby on Rails can handle these issues quite well. RoR can use a load balancer and can provide a sufficient level of performance when processing the increased load of requests, and also allows you to write modular code that can be easily integrated with most database management systems. All of that is possible with appropriate optimization.  

How to scale a Ruby on Rails app?

Scaling a Ruby on Rails application should start with processes that do not create complex scalability. For starters, it’s a good idea to implement code simplification. It requires effort and resources, but it has a positive effect on optimization and the elimination of problems related to it in the future. There are other alternatives, but what directly relates to scaling is horizontal and vertical scaling. 

Horizontal Scalability with Ruby on Rails

In the software world, scaling is about increasing available application resources to bypass resource bottlenecks and degraded performance. Thanks to horizontal scaling, we increase the number of containers, virtual machines or servers for our application by multiplying the available instances. RoR application horizontal scaling means the conversion of a single application server architecture to a three-tier architecture. In this configuration, the server and data packet data module, application instances, and database instances reside on different servers, so we distribute equal and smaller loads between machines. 


Nginx is server software that can also be used as a reverse proxy, load balancer, mail proxy, and HTTP cache. It was designed for high availability and heavily loaded services, with an emphasis on scalability and low resource usage. It is commonly used in Ruby on Rails applications. Nginx requires little computing power to function normally under heavy loads. Nginx’s sole purpose is to filter and spread the load across multiple servers.

Rails App Instances

Additional servers are required to run the application instances independently of the Nginx server. Each of them is connected to a separate application instance to further process user requests. They are responsible for input-output operations. The most popular application servers at the moment are Puma, Unicorn, Phusion Passenger.

Database Instances

There are several options for scaling a Rails application database. We can deploy the database on the same server as the application. It is quite a big saving but has a few drawbacks. When each application instance saves and retrieves data from its database instance, the data for the entire application is distributed across multiple machines. This is very inconvenient for website users who may be redirected by Nginx to a different instance of the application than the one in which its data is stored. This may prevent you, for example, from logging in. Separating the database from other servers is also aimed at creating an architecture resistant to damage and overload. For this reason, the database should be moved to its server. The database can be a single server with the database used by all instances of the application, or it can be composed of several computers running the databases. To update data in all databases, we use database replication.

There are several variants of database replication. Multi-master database replication and master-slave replication are two common approaches to ensuring the consistency of our data layer across multiple databases. Besides, when a database receives a large amount of data, it must respond quickly and save it quickly, update its status and send new data back to the user. It uses PostgreSQL or MongoDB instead of the standard MySQL to hold large amounts of data while scaling the application.

Vertical Scalability with Ruby on Rails

Vertical scaling a Ruby on Rails application seems to be the easiest way to handle the increased RPM by the server. This process means adding more RAM, upgrading the server’s CPU, or in short, adding more processing power. However, there is much talk about the disadvantages of this approach when it comes to RoR applications. Vertical scaling the server the application is running on will only have a positive effect in the early stages. As traffic increases, you will quickly reach the point where upgrading the CPU or adding more RAM is technically unattainable. Besides, when introducing vertical scaling, you must at least increase computing resources for some parts. 

Other Options When Scaling Any Rails App

Scalability is about additional expenses, which must also be considered when planning the development of the application and its improvement in the future. If you want to spare in this process, you have some alternative options. Consider optimizing your code first, ideally creating optimized code during the development phase. It largely depends on the developers and their skills. Now that you have an application ready that was developed rapidly, the chances are that there is a lot of code to refactor and optimize. Therefore, it is worth implementing algorithms that analyze the code, after which developers can rework the code and optimize it for better use of server resources. Another option is to implement a service-oriented architecture to scale your application. The part of the application responsible for a given function can be implemented on a separate server as a standalone application. In this way, the load on the main server will be reduced. Moreover, scaling only this small portion of the RoR application will be easier and cheaper if the load increases again. Service-Oriented Architecture is a great solution for scaling Rails applications and is used by many famous global brands like Spotify.

What are the Most Common Problems with Rails App Scaling

Overall, the biggest problem with Ruby on Rails is the system architecture itself. Building an application based on this framework is not always the best approach when your application is growing rapidly. Aside from performance issues, there may be other issues with scaling issues. The most common are improper memory management, inefficient database engine and caching, bad indexing, code splicing, application server limitations, and much more. However, this doesn’t mean that Ruby on Rails scalability is impossible and always fatal. It is a framework whose huge community has already documented many solutions to problems, which makes it easier to work with RoR. Also, hundreds of open source tools are available to analyze and classify system bottlenecks.

Tips to Scale your Rails Application

Many good practices can help you scale a Ruby on Rails application, the most common of which are:

Common gems

It is recommended that you use common gems to identify problems. Such gems include, for example, the bullet or rack-mini-profiler. This will save you a hefty amount from your budget without paying upfront for extra storage.


Caching means storing the content generated during the request-response cycle and reusing it when responding to similar requests. This is often the most effective way to increase application performance. RoR provides a set of caching features that will ensure fast loading, withstand heavy loads, without exorbitant prices for server maintenance.

Segregate Data 

A good practice that has a positive effect on the scaling of the application is to store data in different places. It is much more cumbersome to analyze large amounts of unstructured data stored in the same place to scale.

So, let’s scale your Ruby on Rails app! Summary

The conclusion may not be very revealing, but the scalability of a Ruby on Rails application depends on the type of project you plan to develop. RoR, like any other technology, may not be suitable for all types of applications, so its application to your software needs to be carefully considered. However, proper use of Rails offers several benefits to your business. Therefore, carrying out an analysis to find the best solutions is essential at the beginning of the road. Scalability is one of the factors that is taken into account in this research. The multitude of Ruby on Rails gems and libraries will certainly solve the problems in many cases, but it also requires the right, skillful developers. We have these in the ranks of BinarApps, so if you want to scale smart and profitably, you can trust us.

You may also be interested in...

Let's bring your project to life

Request a consultation