django-react-boilerplate
django-react-boilerplate copied to clipboard
Set Persistent Connections to a low value by default
https://docs.djangoproject.com/en/3.2/ref/databases/#persistent-database-connections
@fjsj the default CONN_MAX_AGE
is 0
, do you suggest any lower value?
The Heroku docs suggest 500s, the dj-database-url module recommend 600s, some other references recommend 60s.
We need to be careful because If the database terminates idle connections after some time we should set CONN_MAX_AGE
to a lower value.
I also found a few issues related to persistent database connections with async workers on Django. If CONN_MAX_AGE
!= 0 (n or None), Django will reuse the connection (or opens it if it's closed) when needed BUT, apparently it doesn't necessarily close it at the end of requests. This problem doesn't happen with sync gunicorn workers.
@gabicavalcante One of our projects is using CONN_MAX_AGE = 600 w/o problem in production since last week.
We need to be careful because If the database terminates idle connections after some time we should set CONN_MAX_AGE to a lower value.
I think Django manages this well for us, so do you have other concerns?
I also found a few issues related to persistent database connections with async workers on Django.
I think eventlet is something very specific, and we don't use it.