[mod_python] MySQLDb or SQLObject connection pooling snippet wanted

Mike Looijmans nlv11281 at natlab.research.philips.com
Fri Oct 13 07:35:11 EDT 2006

For MySQL, I found that the best approach to connection pooling was "not".

I could not conclude any performance difference opening the same page a few thousand times which 
executed a single SELECT returning a single row with a (mutexed) singleton connection, with a pooled 
set or just connecting for every request. Apparently, the overhead of calling MySQLdb.connect() is 
neglegible compared to all the other stuff that happens (i did this on a SUN Solaris 2.6 running 
Apache 2.0 with worker threads).

The best performance gain is to put the SQL database on the same host and use a UNIX socket (not 
TCP) or a named pipe (on Windows NT) for the connection. I also improved security this way: No one 
can access the MySQL DB from outside the webserver, even if they have the password.

NOTE: This only goes for MySQL. Other DBMS will behave completely different.

Mike Looijmans
Philips Natlab / Topic Automation

Sells, Fred wrote:
> Currently using mod_python 3.1.x and Apache 2.x.  Could upgrade mod_python
> if we must, but this is what apt-get gives us.
> I would like to implement connection pooling for the MySQL database.  Based
> on the application requirements, we vary between MySQLDb and SQLObject.
> The only reference I've found so far is jonpy.sourceforge.net Does anyone
> have any "better" modules or any experience with this one?
> ---------------------------------------------------------------------------
> The information contained in this message may be privileged and / or
> confidential and protected from disclosure. If the reader of this message is
> not the intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If you
> have received this communication in error, please notify the sender
> immediately by replying to this message and deleting the material from any
> computer.
> ---------------------------------------------------------------------------
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list