[Mongrel] Recommentation: Sessions and PStore

Joe Ruby joeat303 at yahoo.com
Sat Sep 9 13:58:25 EDT 2006


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.

Joe


---

1) DON'T USE PSTORE AS A SESSION STORE!

All of the people who had Mongrel processes going
crazy, blocking,
locking, or just generally doing bad things had a
pstore as their
session storage option.  What happens is the pstore
isn't that great
when multiple processes access it, and if one Mongrel
has problems
pulling an object from the pstore then it'll explode. 
Use the file
store when you develop, and use the database or
memcached store in
production.

You should also be looking for other ways processes
are sharing
resources when they lock up or do weird things.  Try
running with just
one process, and if you don't have any problems then
it's a resource
locking problem (most likely).

2) DON'T STORE COMPLEX OBJECTS IN THE SESSION!

This especially goes for you Java people who think the
session store is
a temporary database.  The session really only works
for simple types
like integers, strings, etc.  You *must* follow the
mantra of "Share
Nothing" and either store everything in the database
or use form fields
and GET parameters to make it stateless.  As I've said
repeatedly, "If
rails-core don't do it, you don't do it."  Rails-core
does not do this.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mongrel-users mailing list