[mod_python] Sessions performance and some numbers

dharana dharana at dharana.net
Thu Apr 7 06:08:06 EDT 2005


Graham Dumpleton wrote:
> 
> On 07/04/2005, at 5:31 AM, dharana wrote:
> 
> [...]
> 
> 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.

I've made a basic FileSession class. Please look at this numbers (I did 
the test 10 times each and averaged:

With a clean mp_sess dbm db:

   ab -n 100 http://localhost/sessions_dbm.py
   Requests per second:    83.03 [#/sec] (mean)



With an mp_sess dbm db with 1500 sessions:

   ab -n 100 http://localhost/sessions_dbm.py
   Requests per second:    6.05 [#/sec] (mean)



Same tests with the single but working FileSession implementation show this:

No files in tmp dir:
   ab -n 100 http://localhost/sessions_file.py
   Requests per second:    189.14 [#/sec] (mean)

With 1500 files in tmp dir:
   ab -n 100 http://localhost/sessions_file.py
   Requests per second:    166.67 [#/sec] (mean)


Before each test I did the following:

- apachectl restart
- ran a preliminar ab -n 500 so modules get loaded and cached
- erase the session files without restarting apache
- ran each test

> 
> 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.
> 

If you want I can send my modified Session.py with the new FileSession 
class for review. The only thing left is the possibility of specifying 
hash dirs to store the files to improve scalability over very busy sites.

-- 
Juan Alonso
http://gamersmafia.com | http://laflecha.net



More information about the Mod_python mailing list