Monday, July 23, 2007

Wanna make your Rails app faster?


Get rid of sessions!
Yes you can get rid of sessions for apps that run too slow for your comfort. Ofcourse flash errors won't show up and other stuff that uses sessions. But definitely there are other ways to do flash errors and logins and other "session" stuff in a sessions disabled environment.

So go on and say
session :disabled => 'true'
in you
r application controller and feel the difference

Friday, July 13, 2007


Chat in console with finch...It's very fast and eats very less memory, supports all the major protocols but the best part is that your boss won't be able to catch you :)

Thursday, July 12, 2007

Writing a custom mongrel handler

Wrote my first custom mongrel handler and it is ugly. I have not used ERB, eruby or erubis yet to generate HTML.

Benchmark results for mongrel handler

Transactions: 5000 hits
*Elapsed time: 54.55 secs
*Data transferred: 2.90 MB
*Response time: 0.45 secs
Transaction rate: 91.66 trans/sec
*Throughput: 0.05 MB/sec
*Longest transaction: 1.63
*Shortest transaction: 0.00

A similar app on rails was made and here are the benchmark figures

Transactions: 5000 hits
*Elapsed time: 195.34 secs
*Data transferred: 3.39 MB
*Response time: 3.29 secs
**Transaction rate: 25.60 trans/sec
*Throughput: 0.02 MB/sec
*Longest transaction: 7.63
*Shortest transaction: 0.01

There is almost a 4 fold jump in transaction rate and therefore Mongrel handler can be used to handle pages which have very high hit counts
However using plain vanilla mongrel handlers to write pages is very difficult as it does not automagically 'renders' html pages.

Monday, July 09, 2007


After 3 months with Ruby, I think it's a great language. It may not be as fast as C or Perl but it is very developer-friendly. It's 100% object oriented. That means everything is an object and hence everyobject can be manipulated by some very useful set of methods that are provided with the language
So you can say something like this => 13
12.remainder(5) => 2

It also supports some of the very powerful features of Lisp(Greatest language ever !) like unnamed functions, blocks, iterators etc

"A quick brown fox jumped over a lazy dog".downcase!.split(//).sort.uniq.each {|char| print char+" "}
a b c d e f g i j k l m n o p q r u v w x y z

Being 100% OOPs is one of the strongest features of this language

1.upto(10){|i| puts "9 X #{i} = #{9*i}"}
will give you table of 9
9 X 1 = 9
9 X 2 = 18
9 X 3 = 27
9 X 4 = 36
9 X 5 = 45
9 X 6 = 54
9 X 7 = 63
9 X 8 = 72
9 X 9 = 81
9 X 10 = 90

It offers "minimum surprise" to a newbie and the code is very easy to read.

Though there are some downsides also as it is interpreted only language and can be slow. But come Christmas 2007 a new ruby version is being released which hopes to solve this problem to some extent.