session :off !
Posted 05 Nov 2005
Rails 0.14 contains the possibility to turn off sessions on a controller or even action basis.
class WelcomeController < ApplicationController
session :off
...
end
This will turn off session creation and update on all actions of class WelcomeController.
Depending on the complexity of the logic inside your actions, you can get a big speedup. For example, on my welcome controller, index is action cached. Turning sessions off for this action, I see a huge performance improvement on my windows development box:
c1 real c2 real c1 r/s c2 r/s c1 ms/r c2 ms/r c1/c2 2.29700 0.27633 217.7 1809.4 4.59 0.55 8.31 2.45833 0.29200 203.4 1712.3 4.92 0.58 8.42
This was measured against the default ActiveRecordStore session implementation. But even with a faster session implementation, the difference is astonishing:
c1 real c2 real c1 r/s c2 r/s c1 ms/r c2 ms/r c1/c2 1.20333 0.26600 415.5 1879.7 2.41 0.53 4.52 1.35933 0.27633 367.8 1809.4 2.72 0.55 4.92
So it is certainly worthwhile to consider turning sessions off for controllers that don't need them.