Not respecting Django's CONN_MAX_AGE database setting
See original GitHub issueHi,
I’m using uvicorn
with gunicorn
.
I have assigned CONN_MAX_AGE setting a value say 300 but its closing the connection instantly after completing the request.
My gunicorn configuration is like,
bind = ‘0.0.0.0:8000’ workers = 3 secure_scheme_headers = {‘X-FORWARDED-PROTO’: ‘https’} reload = True errorlog = ‘-’ loglevel = ‘debug’ worker_class = ‘uvicorn.workers.UvicornWorker’
And i’m running the following command to start the server,
gunicorn -c gunicorn.conf.py myproject.asgi:application
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Django CONN_MAX_AGE is set to 0 but connection remains ...
I have a problem where old connections stay open in idle state in the db. My request is: MyTable.objects.all().first().id. I use the following...
Read more >Reduce no. of DB connection with Django - Medium
Solution: So we changed the settings like the following and our concurrent connection number changes drastically. 'CONN_MAX_AGE': 0.
Read more >Settings - Django documentation
Here's a list of settings available in Django core and their default values. ... When set to True , if the request URL...
Read more >Databases | Django documentation
To enable persistent connections, set CONN_MAX_AGE to a positive number of seconds. ... Django needs the following parameters for its database connections:.
Read more >Django: CONN_MAX_AGE persists connections, but doesn't ...
7 and Postgres 9.3 on Ubuntu 14.04 LTS. At any given time, the site gets about ~250 simultaneous connections to the PostgreSQL database,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I do not think this is a uvicorn issue.
I this this provides some more light: https://github.com/benoitc/gunicorn/issues/996 although I was not able to solve the problem yet.
Not sure, but this needs raising on channels or django or something - its not a uvicorn issue.