[Proposal] Exploring Native Database Connection Pooling Support in Django ORM

Hi Django community :waving_hand:,

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!


:brain: 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.


:magnifying_glass_tilted_left: 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.


:light_bulb: 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.


:thinking: 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! :folded_hands:
Looking forward to hearing thoughts — and if I get access to Internals, I’ll gladly move the discussion there.

5.1 introduced pools for Postgres Django 5.1 release notes | Django documentation | Django

and briefly searching through tickets it would seem other backends have been considered and worked on before. (#7732 (Oracle Backend with SessionPool) – Django, #35702 (Clarify mysqlclient does not provide connection pooling) – Django)

I would suggest you do some more research via code.djangoproject.com to see what has been done and if there are any gaps left which you could fulfill.

1 Like