Home Platform Services Portfolio Team Blog Contact us
GuruOnRails

Hot Item - Get a FREE Project Estimation! Click here to proceed!
 
RoR application performance
 
Add to Google Add to Delicious Digg it Add to FURL Add to Newsvine Add to Netscape Add to Reddit Add to STUMBLEUPON Add to MAGNOLIA Add to TECHNORATI

Today we will tell you how easily you can optimize your application. By making simple modifications you can achieve an increase of performance and reduce load on server. It is the first post to the topic of Ruby on Rails application performance. That’s why, we will study general and simple things concerning optimization of application functioning.

Let’s start studying this list.

1. Optimization of computations in the application.

It is necessary to avoid unnecessary repeated calculations. It especially concerns processing of big volumes of data. If you need to use a computed value many times, try to do with a one-time computation. It is better to cache a computed value and make repeated computations only in case of necessity.

If your application contains data not changing in the process of application work, then computation of these data should be made once – at the start of your application.

2. Optimization of database queries.

Ruby on Rails makes work with database easier and takes all low-level work on itself. However, it is not always optimal from the point of view of performance.

Suppose that at the execution of such a request:

Articles.find(:all, :conditions=>…)
We receive N objects of Article class. Then we want to address to the author of the article via automatically generated accessors:
Arcticle.author.name
Then we get N queries more, which increases the load on database and application server. It is possible to avoid this using the following construction:
Articles.find(:all, :conditions=>… , :include=> :author)
It will solve the problem of unnecessary queries to the DB.

3. Non-optimal use of helpers.

As we know, helpers significantly simplify developer’s life. But, everything good should be within reasonable limits. For example, an excessive use of helpers for building links on pages can seriously reduce the speed of page display. Sometimes it is advisable to use HTML-tag to create a link. It will be faster from the point of view of application efficiency.

In conclusion we would like to note, that all advantages of Ruby on Rails should be used sensibly and without detriment to your application. In our next posts, we will touch the problem of Ruby on Rails application efficiency in detail. The post was prepared on the materials from InfoQ.

Konstantin
03 Aug 22:42
0
 
 
Add to Google Add to Delicious Digg it Add to FURL Add to Newsvine Add to Netscape Add to Reddit Add to STUMBLEUPON Add to MAGNOLIA Add to TECHNORATI
Only registered users are allowed to leave comments. Please, register.