[BangPypers] Django connection pooling using sqlalchemy connection pool

Anand Agarwal anandagar at gmail.com
Wed Jul 11 21:19:59 CEST 2012

As you know, Django  <https://www.djangoproject.com/>uses new database
connection for each request. This works well initially. However as the load
on the server increases, creating/destroying connections to database starts
taking significant amount of time.  You will find many questions about
using some kind of connection pooling for Django on sites like
StackOverflow   <http://stackoverflow.com/>For example, Django persistent
database connection.

At BootStrapToday <http://bootstraptoday.com/> we use
connection pooling mechanism with Django for pooling the database
connections. We use variation of approach by Igor
Katson<http://stackoverflow.com/users/37511/igor-katson> described
in http://dumpz.org/67550/.  Igor’s approach requires patching Django which
we wanted to avoid. Hence we created a small function that we import in one
of __init__.py (or models.py) (i.e. some file which gets imported early in
the application startup).

Here is more detail on how we do it at


More information about the BangPypers mailing list