Hi Django community ,
I’m currently working on some high-load projects and wanted to bring up a topic that feels increasingly important — native support for database connection pooling in Django.
I realize this probably belongs in the Internals category, but I don’t yet have posting permissions there. I’m sharing it here to get feedback and start a discussion — happy to repost it in Internals when possible!
Why this matters
In Django, CONN_MAX_AGE
helps with persistent connections, but it doesn’t provide true connection pooling like you’d get with SQLAlchemy in FastAPI or similar frameworks.
In contrast, SQLAlchemy gives you:
- Configurable pool sizes
- Queueing and timeout behavior
- Recycle/reconnect logic
- Pool health insights
This makes a huge performance difference for apps with high concurrency, short-lived processes (e.g. in serverless), or async workflows.
Current Django Workarounds
Some common strategies we use today:
- External tools like pgbouncer
- Third-party libraries like
django-db-geventpool
- DIY solutions or monkey-patching backends
But none of these feel native to Django or widely documented, and they’re not always obvious to developers starting out.
What I’m proposing
Would it make sense to explore:
- Pluggable pool support via the
DATABASES
setting - Native connection pooling logic (opt-in, maybe backend-specific)
- Exposing pool stats or metrics
Even a minimal version — something closer to SQLAlchemy’s QueuePool
— could go a long way.
Open Questions
- Has this been considered before?
- Is there a specific architectural reason Django ORM doesn’t offer this natively?
- Would the community be open to a discussion or draft proposal?
Thanks for reading!
Looking forward to hearing thoughts — and if I get access to Internals, I’ll gladly move the discussion there.