Storing Sessions in Memcached
Twitalytics needs to track how many posts users create between the time they log in and the time they log out. This count is stateful and must be carried across transactions, survive any restarts of the application process, and be accessible from multiple processes when the app is scaled out. For these reasons, the count must be stored in a user’s session.
Each time a user starts an interaction with a web page, a session is created. The session stores state that’s carried over from one request to another for the same user. It usually includes things like username, breadcrumbs to track where they’ve been in the app, and even security tokens.
The default session storage mechanism in Rails is cookie based, which ...