Django connection pooling using sqlalchemy connection pool

249 views
Skip to first unread message

Anand Agarwal

unread,
Jul 11, 2012, 3:37:00 PM7/11/12
to django...@googlegroups.com
As you know, Django 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 likeStackOverflow  For example, Django persistent database connection. 

At BootStrapToday we use sqlalchemy‘s connection pooling mechanism with Django for pooling the database connections. We use variation of approach by 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 BootStrapToday 

Regards
Anand

Russell Keith-Magee

unread,
Jul 11, 2012, 7:45:16 PM7/11/12
to django...@googlegroups.com
On Thu, Jul 12, 2012 at 3:37 AM, Anand Agarwal <anan...@gmail.com> wrote:
> As you know, Django 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 likeStackOverflow For example, Django
> persistent database connection.

There is a reason that Django doesn't manage connection pooling --
it's because it's handled quite well by third party tools like pgPool.

Yours,
Russ Magee %-)

Javier Guerra Giraldez

unread,
Jul 12, 2012, 10:34:55 AM7/12/12
to django...@googlegroups.com
On Wed, Jul 11, 2012 at 6:45 PM, Russell Keith-Magee
<rus...@keith-magee.com> wrote:
> There is a reason that Django doesn't manage connection pooling --
> it's because it's handled quite well by third party tools like pgPool.

is there any similar tool for mysql? i've seen a few, but doesn't
look so well accepted as Postgre ones

--
Javier
Reply all
Reply to author
Forward
0 new messages