Search code examples
djangoconnection-poolingdjango-1.7pgpoolpgbouncer

django 1.7 and connection pooling to PostgreSQL?


What are the differences between the django apps (Django-PostgresPool, djorm-ext-pool, django-db-pool) and PG Bouncer or PG Pool?

Do the apps use one of the last two packages?

In this article, the author says that there is a patch starting with django 1.6. Does that mean we do not have to use any of these solutions anymore, neither the apps, nor the PG Bouncer or PG Pool package?


Solution

  • Postgres database connections are expensive (resources) compared to MySQL connections. Django pooling apps will open many connections and keep the open.

    PG Bouncer and PG Pool will open fewer connections to Postgres, while maintaining a large number of local connections (app to PG Bouncer/PG Pool) and reuse them.

    For best performance you want both: persistent connections from Django to PG Pool / PG Bouncer.

    In our case switching persistent connections reduced average response time by 10ms (over 20%) on AWS.