Hi Hans, I know this isn't really solving your issue, but it can remove a symptom. I have successfully used pgBouncer to pool the connections, so that connections aren't handled by django directly, but you connect to a connection pool, so that it can create and reuse connections more efficiently. See https://wiki.postgresql.org/wiki/PgBouncer.
That would probably solve the symptoms of your problem, but not the problem itself. Regards, Andréas 2015-03-20 16:52 GMT+01:00 Hans Kristian Flaatten <hans.krist...@dnt.org>: > My Django application is exceeding the maximum number of simultaneous > database > connections (100) to the Postgres database when running through Gunicorn > with > async eventlet workers. When the limit it exceeded it starts returning > 500-errors until new connections can be established. > > Setting `CONN_MAX_AGE` to 0, 60, 600, or None does not appear to solve > this issue. > > *This is my database configuration:* > > DATABASES = { > 'default': { > 'ENGINE': 'django.contrib.gis.db.backends.postgis', > 'NAME': 'django', > 'USER': 'django', > 'HOST': 'postgres', > 'PORT': 5432, > 'CONN_MAX_AGE': 60, > } > } > > *This is my Gunicorn configuration:* > > gunicorn --bind 0.0.0.0:8080 --worker-class eventlet --workers 5 myapp. > wsgi:application > > *These are the installed packages:* > > - djano v1.7 > - gunicorn v19.3 > - eventlet v0.17 > - psycopg2 v2.6 > > Any hints or tips on where to go from here? Is Django's ORM supposed to > offer > connection pooling/reuse, or is this something I have to get else where? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/a5bd0b59-638c-466d-9f85-aadd5edda500%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/a5bd0b59-638c-466d-9f85-aadd5edda500%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUbnWG-%2BpjoS6vmHvBmGdJZMpKQw8%3DaV0kw6d0eHDPCGq3w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.