[mod_python] persistent, reliable globals

Michael S. Fischer michael at dynamine.net
Tue Mar 9 15:33:07 EST 2004

Alain Tesio writes:

> It sounds quite silly to store data on disk to share objects 
> which may not even need to be stored at all, if the point is 
> to have objects in memory and not read/write/pickle/unpickle 
> them all the time and managing locks too.

When you have a hammer (e.g. pickle), everything looks like a nail, I

Don't underestimate the power and speed of the filesytem, particularly if
you're using a decent storage API like Berkeley DB.  Using disk storage
doesn't have all the drawbacks you might believe.  Most importantly, if
you're using a modern OS, your performance will be close enough to mmapped
I/O due to buffer caching.

Plus you get the benefit of persistence across machine reboots or server

Besides, coding man-hours are expensive, while RAM and disk is cheap.

Lock concerns?  Use rename() (safest) or fcntl.flock()/lockf() (can handle
multiple readers, but not NFS-safe; if you're using NFS, you won't get
buffer cache benefits anyway, so I don't recommend it).


More information about the Mod_python mailing list