Reputation: 557
I was looking at db connection pool implementations to use in my Django app using postgresql db backend, and came across this very recent wrapper package implemented for psycopg2 -
https://pypi.python.org/pypi/django-db-pool
psycopg2 in itself offers different types of pools i.e. Simple (shared across single thread), Threaded (shared across threads) and Persistent (strictly one persisted connection per thread), according to the docs here - http://initd.org/psycopg/docs/pool.html.
djang-db-pool seems to be using the ThreadedConnectionPool
implementation, as seen from the source code.
Currently, in my Django app implementation, each request can spawn off multiple threads, which means to handle multiple concurrent Django requests, is ThreadedConnectionPool
the right way to go ?
Does anybody else have some experience using this package (django-db-pool) or psycopg2 connection pool with Django and can throw some light on this ?
Upvotes: 3
Views: 2803
Reputation: 1898
As the docs you linked to note, ThreadedConnectionPool
is the one you want to use for multi-threaded applications, which Django is (or can be anyway, depending upon how you've configured your web server / WSGI interface.) I wrote django-db-pool so I'm not an impartial source, but perhaps you could explain your request flow so I could offer some additional advice?
Upvotes: 2