Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32305 closed New feature (wontfix)

Add an option to limit the number of connections to a database

Reported by: Barney Szabolcs Owned by: nobody
Component: Database layer (models, ORM) Version: 3.0
Severity: Normal Keywords: db connection leak
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Barney Szabolcs)

With the introduction of threads in Django 3.0, somehow only changing from Django 2.2.x to Django 3.0 causes the number of connections to build up, with each request a new connection being added.
Probably this pile-up is because of some bug in one of the Django-related packages. However, it would be nice to have a safety feature in Django not to exceed a limit of database connections. It would make the whole system a lot more robust.
(At the moment it is not even worth to switch for some long term users who use a long list of packages along with Django because the db connection buildup has no straightforward solution, yet.)

Change History (3)

comment:1 by Barney Szabolcs, 3 years ago

Description: modified (diff)

comment:2 by Carlton Gibson, 3 years ago

Component: Core (Other)Database layer (models, ORM)
Resolution: needsinfo
Status: newclosed
Type: Cleanup/optimizationNew feature

Hi Barney.

With the introduction of threads in Django 3.0, somehow only changing from Django 2.2.x to Django 3.0 causes the number of connections to build up, with each request a new connection being added.

This is something worth looking at if you can demonstrate it with a minimal project. There really shouldn't be a regression here.

In general I think tracking connections isn't in scope for Django itself. We'd suggest using a connection pool (e.g. PgBouncer) for your database, or similar approaches.

comment:3 by Carlton Gibson, 3 years ago

Resolution: needsinfowontfix

I'll mark this wontfix on the new feature, but happy to review an example showing the issue (hence the initial needsinfo) – hope that makes sense.

Note: See TracTickets for help on using tickets.
Back to Top