Top 5 Ruby on Rails performance tips for the small business

2015 is the 10th birthday of Ruby on Rails (or simply called Rails), the popular open source web application framework that uses the Ruby programming language. Ever since Rails burst on the scene a decade ago it has continued to scale up as an elegant way to build dynamic websites quickly and efficiently. Rails has garnered a strong following, especially among tech startups. In fact, some of the best known firms out there are using the framework to build their sites. Examples of elegant sites built on Rails are GrouponAirbnb, and Bloomberg.

 

Ruby1

 

The irony of Rails is that even though it was originally designed as an easy way to learn code and build sites, it has become quite “complex.” One writer captures the sentiment this way:

 

For something that is touted as being an “easy” to use framework, Rails is a pretty complex beast. Over the years it has progressed from a seemingly simple framework that “anyone” can learn to the intricate collection of add-ons, gems and extensions that make it the power house it is now.

 

Indeed, Rails is a great ecosystem that is used by startups, small businesses, and enterprises alike to build cool, interactive websites. What’s more, if you using Rails then you’re going to want to get the most mileage from the framework. You’re going to want to optimize, expand, and build upon the simple and elegant tools and resources that help make Rails what it is. Therefore, in what follows we want to outline 5 key performance tips, or best practices, which will help you maximize your Rails shop and make it an even more powerful tool in your web development arsenal.

 

1. Caching

 

You’ve probably heard this term before. Caching is a mechanism for the temporary storage of web pages in order to reduce bandwidth and improve performance. This saves server time and makes things altogether faster. It’s a common practice in web development and is fairly straightforward to implement in Rails applications. For an overview of the various caching options and updates in Rails, see the RailsGuides documentation here.

 

2. Content Delivery Network

A content delivery network is a way of taking a website’s static files, like CSS, images, and JavaScript, and delivering them through web servers that are closer to the user’s physical location. Shorter proximity amounts to faster load time and ultimately better performance. But another benefit is that by offloading the bandwidth you also get less risk of downtime disruptions due to traffic volumes. One development expert calls CDNs the “ultimate low-hanging fruit optimization” for Rails and other frameworks. From a cost, efficiency, and scalability perspective, the best resource for making this happen on Rails is Amazon CloudFront.

 

Ruby2

 

3. Minify CSS stylesheets and JavaScript

 

Code optimization is one of the best ways to increase performance, no matter what framework or language you’re using for development. The most common approach is by minifying and concatenating multiple code files into one. For example, if your app has five JavaScript files the browser will make five separate HTTP requests to fetch them. To avoid the block and wait time, an alternative approach would be to minify and concatenate those 5 files into one streamlined one. Rails makes it especially easy and intuitive to minify files through its assets pipeline. This built-in feature concatenates and compresses JavaScript and CSS assets and also enables writing these assets in other languages and pre-processors such as CoffeeScript, Sass and ERB.

 

4. Use background processing

 

There’s a lot going on under the hood whenever a web request is made. For example, emailing users, running reports, processing images, updating counters, sending info to external API’s, and search engine indexing are all examples of background processes. The trick is to ensure these are optimized and handled automatically without slowing down the actual application response. Fortunately, there are tools out there like Sidekiq or Resque, which are specifically designed for use on Rails to help manage your background jobs and to ensure they are processed efficiently.

 

5. Cloud-based application performance monitoring

 

Your high-end Rails apps are only as good as the performance of your infrastructure, which is why application performance is too important to leave to chance. What this requires is the best-in-class monitoring capability for all your IT systems. That’s exactly what you’ll find in Monitis. As the trusted leader in this market, Monitis offers a 24/7 cloud-based monitoring platform for websites, servers, applications, and networks. Through an easy to follow and intuitive web-interface, Monitis tracks all of your business-critical applications to ensure everything is running optimally and that you’re alerted to issues long before your customers are. In fact, the mobile version of Monitis allows you to get the latest metrics and push notifications delivered to your Android and iPhone/iPad devices.

 

Ruby3

 

If you’d like to get onboard with the latest in real-time, cloud-based web app monitoring then go on over to Monitis and start a free trial today. Knowing that your Rails apps are entrusted to a proven industry leader like Monitis will give you the peace of mind you deserve.

 

You might also like