Optimizing Ruby on Rails for performance and scalability

University essay from KTH/Skolan för datavetenskap och kommunikation (CSC)

Author: Kim Persson; [2016]

Keywords: ;

Abstract: Web applications are becoming more and more popular as the boundaries of what can be done in a browser are pushed forward. Ruby on Rails is a very popular web application framework for the Ruby programming language. Ruby on Rails allows for rapid prototyping and development of web applications but it suffers from performance problems with large scale applications. This thesis focuses on optimization of a Ruby on Rails application to improve its performance. We performed three optimizations to a benchmark application that was developed for this project. First, we removed unnecessary modules from Ruby on Rails and optimized the database interaction with Active Record which is the default object relational mapping (ORM) in Ruby on Rails. It allows us to fetch and store models in the database without having to write database specific query code. These optimizations resulted in up to 36% decrease in application response time. Second, we implemented a caching mechanism for JavaScript Object Notation (JSON) representation of models in the optimized application. This second optimization resulted in a total of 96% response time decrease for one of the benchmarks. However, we also observed an increased response time (with approximately with 15%) for a second benchmark compared to the unoptimized application. Third, we tuned the garbage collector for CRuby. CRuby is the original implementation of Ruby created by the inventor of the language Yukihiro Matsumoto. This optimization was performed on top of the already optimized application with caching and resulted in an overall decrease in response time: one benchmark showed a response time decrease of 29% with regard to the unoptimized application. In addition, we evaluated the performance of different Ruby implementations: we studied the performance of the application with CRuby, JRuby and Rubinius. We observed that JRuby had the best performance. When the optimized and cached application executed in JRuby it obtained a decrease in response time of up to 32% with regard to the unoptimized application in CRuby. In conclusion, we presented that different optimization techniques can be applied to improve Ruby on Rails performance leading to maximum performance increase of 96%. In addition, we showed that the choice of Ruby implementation is very important as the JRuby implementation has potential to further increase application performance. This work is very important for future development and success of the Ruby on Rails framework as performance is largely seen as the biggest disadvantage with the framework.

  AT THIS PAGE YOU CAN DOWNLOAD THE WHOLE ESSAY. (follow the link to the next page)