0

I want to sanity check my understanding of Heroku's Postgres Connection Limit.

I currently use the Postgres Standard 0 addon which has a Connection Limit of 120. I am also running a Django application in two Standard 1x dynos. Each dyno runs the application using gunicorn with two workers.

So firstly am I correct in assuming my application can handle four requests at any one time?

Second will I ever reach the Postgres Connection Limit? I assuming not as there will only ever be four connections to Postgres at any one time.

Neil
  • 8,925
  • 10
  • 44
  • 49
  • I found the answer on Heroku https://devcenter.heroku.com/articles/python-concurrency-and-database-connections – Neil Sep 12 '18 at 10:15

2 Answers2

0

The answer is no, I won't run into the Postgres Connection Limit with this setup. At most there will four connections to Postgres.

Heroku have gone into detail this here https://devcenter.heroku.com/articles/python-concurrency-and-database-connections

I think the only time you need to worry about reaching the connection limit is if you are using an async server.

Neil
  • 8,925
  • 10
  • 44
  • 49
0

Your best bet is to either use connection pooling via an ORM, or pgbouncer. I wrote my own async threaded connection for psycopg2.

You can find my code in this answer here:

Python Postgres psycopg2 ThreadedConnectionPool exhausted

eatmeimadanish
  • 3,809
  • 1
  • 14
  • 20