[Mongrel] Recommentation: Sessions and PStore
zedshaw at zedshaw.com
Sat Sep 9 17:19:13 EDT 2006
On Sat, 2006-09-09 at 10:58 -0700, Joe Ruby wrote:
> Uh oh! I'm sort of guilty of both #1 and #2! I'm not
> having any performance problems, but...
> I've been using the file store for sessions -- how
> much faster is using the database or memcached? I
> always thought files were quicker than the db
> (especially since each session gets its own file).
> I've been sticking the member object in a session when
> they login, and only updating it if they change their
> info. I was using the same assumption that files were
> quicker than the db.
Well, two points here. First, if you're going to store this member
object in the database using session, why just skip the middle man and
store it in the database directly? Session is slower than database for
any sort of complex objects because it has to marshal/unmarshal while
the AR system can use delta storage and other tricks (and even memcache
Second, have you tested this hypothesis? Write a simple benchmarking
rails action that stores/retrieves a bunch of random member objects from
the database and then from your chosen session store. I found that
storing small stuff like strings, numbers, etc. is faster, but that any
complex types are nasty slow.
So, test it first, use the database or memcache if session storage is
faster (for stability), and use the database by default in general.
Zed A. Shaw
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.
More information about the Mongrel-users