Rails performance tips

I have done some research through the weekend about improving Rails Applications performance. I would feel the the following few points need to be considered when we optimize rails applications for performance:

1) Avoid the use of dynamic URL generation (link_to, url_for) since rails needs to look up the routes table and that may take time. Just hard code the controller name and the action.

2) Try to avoid the excess use of helpers since it adds overhead.

3) You may consider to use Rails Bench to do some testing for you rails application performance.

4) You may consider to use memcached to cache your model and library computation results.

5) you may consider partial caching for your view partials.

6) try to optimize your database queries. If you use ActiveRecord find, be careful from computation intensive sql queries that returns to you a lot of data that you may not need. The method find may run many select statements for you.

These are very few tips, I will write about Rails performance in more details soon.


Comments (2)

Rails 404 (Not Found)

This is how you issue 404 in Rails:


Comments

Ruby hash merge (Add element to Ruby hash)

This sample shows how to add element to ruby hash


Comments (4)

Ruby Numbers Swap

How cute! Single line swap in Ruby. When I tried to do a single line swap in C, it was something like a^=b^=a^=b.


Comments

Ruby Characters to ASCII

This piece of code converts Ruby Characters to ASCII code and vice versa.

Comments

Slice Ruby String

These are different ways to divide or slice ruby string. All of these statements gives the same output.

Comments

Ruby String successor

This is a simple example that shows how ruby string successor works.

Comments

Email validation using ruby

The following piece of code validates any email that ends with .com, .edu, .org or any three letter extension. It uses regular expressions to find a match.

Comments (5)

Reverse Ruby String Words

In my last post, i gave a simple snippet to reverse ruby string. Here, I am giving simple snippet to reverse ruby string words. So, given string like “ruby on rails”, the output going to be “rails on ruby”.

Comments (3)

Reverse Ruby String

This how we reverse entire string in ruby :

To reverse ruby string words, check this link.

Comments

« Previous entries · Next entries »