What is a good value for CONN_MAX_AGE in Django?

Brendan Nee picture Brendan Nee · Nov 12, 2013 · Viewed 22.1k times · Source

Django 1.6 now supports CONN_MAX_AGE to pool database connections.

By default, the value is 0 (no pooling). What is a sensible value for this option?

Answer

MGP picture MGP · Feb 12, 2014

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.