Description
Following this code without ability to set GUNICORN_WORKERS
we have number of workers equal to number_of_cpus*4+1
.
Django's default behaviour is to open connection per worker for GUNICORN_WORKERS
times and keep them opened for CONN_MAX_AGE
seconds.
CONN_MAX_AGE
is strictly set right in code for 600 seconds and max_connections
parameter of PostgreSQL in deis-database
strictly set to 100
too.
So, lets imagine, we have a big metal chassis with 40 CPUs.
Our GUNICORN_WORKERS
variable will be equal to 40*4+1=161
(which is already greater than 100), also, we have CONN_MAX_AGE
parameter equal to 600 seconds.
This way after 500 seconds (health check is once per 5 seconds, 100 times) queries like SELECT 0
which are results of health check will own all 100 connections to PostgreSQL.