[mod_python] Sessions performance and some numbers

Nicolas Lehuen nicolas.lehuen at gmail.com
Thu Apr 7 18:23:46 EDT 2005


On Apr 7, 2005 11:42 PM, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> I am going to show my ignorance of how sessions are internally
> implemented
> here, but what happens if you happened to have two distinct instances of
> Apache running on the same machine? Ie., not one instance of Apache
> listening
> on two ports, but two instances each listening on their own ports.
> 
> What I am getting at here is that will both instances of Apache if using
> mod_python, use the same "mp_sess.dbm" file in "/tmp". Is the way that
> information is stored in the database about sessions mean that each
> instance
> of Apache sees a different set of session information, or because it is
> the
> same database, the session information is effectively shared between the
> two and thus a user could login to a session through one instance of
> Apache and pick up that session automatically through the other.
> 
> Note I am not talking here about prefork and multiple Apache sub
> processes,
> I am talking about multiple instances of Apache as a whole.
> 
> I haven't looked at the FileSession code yet, but what would it do in
> this
> case.
> 
> Anyway, I know that in practice this may be rarely done, but just
> curious.
> 
> Graham

Currently, DBMSessions are stored in a directory return by tempdir().
Under Windows, this always returns the same temporary directory
(e:\windows\temp on my machine). So both instances will work on the
same DBM file. Now, if the dbm implementation is bsddb, it should pose
no problem. If it is another implementation, you can expect big
problems.

With this implementation of FileSession, a collision is also possible,
but it will happen only of the two Apache instance build the same
session id. As long as no two session have the same session id,
everything will be allright. If a collision occurs, only the two
sessions will suffer, the other ones will still be OK. So I guess
FileSession would handle this situation more gracefully.

Anyway, I think the directory where session data is stored should be
defined by a PythonOption directive, it would be cleaner.

Regards,
Nicolas


More information about the Mod_python mailing list