34👍
✅
This value depends on the traffic of your site, the more traffic the more seconds to retain the connection, I’d recommend setting a relatively small value like 60
and tuning it accordingly to the usage pattern.
Edit (2018):
Like @jcyrss pointed out, this method has its quirks, for future reference I’d recommend handing out pooling to something like pgbouncer instead.
👤MGP
36👍
Not as simple as “the more traffic the more seconds to retain the connection”.
It also depend on how you run Django.
Now, one popular way to launch Django in gunicorn+greenlet(evenlet or gevent). And if you set CONN_MAX_AGE to 60 (even 5 in my case), you may get complain ‘too many connections’ from DB server.
See this for details.
- [Django]-How to concatenate strings in django templates?
- [Django]-"{% extends %}" and "{% include %}" in Django Templates
- [Django]-Why does Django's render() function need the "request" argument?
Source:stackexchange.com