[mod_python] Sessions performance and some numbers

Graham Dumpleton grahamd at dscpl.com.au
Wed Apr 6 17:35:47 EDT 2005


On 07/04/2005, at 5:31 AM, dharana wrote:
> ab -n 100 http://localhost/python_session.py
> Contents of python_session.py
> ---------------
> def handler(req):
>   from mod_python import Session
>   req.sess = Session.Session(req)
>   req.sess.save()
>   return
> ---------------
>
> 8 req/sec !!!!
>
> As we can't use MemorySession on Linux (Linux is multiprocess, right?)
> what are the possible alternatives?

On Linux, you could build Apache with the worker "MPM" and restrict the
number of processes to 1 but many threads and then a MemorySession would
be used.

> Would a custom FileSession ala PHP
> be faster?
>
> I found an old post from 2001 where some people recommended using a
> custom Session Server but I don't know if this recommendation still 
> holds.

Someone posted something a bit more recent which used a database for
doing sessions.

   http://www.modpython.org/pipermail/mod_python/2005-March/017651.html

Thus that sort of thing is definitely possible.

My only other comment is to ask that you made sure you weren't testing
immediately after an Apache restart and before any other requests had
come in, but after already having done some requests. I ask this because
there will be some initial startup costs for loading of modules etc,
although how much depends on your code a bit. Thus, you should try to
make sure you factor out such possibilities.

Graham



More information about the Mod_python mailing list