Database connection count growing with deploys

We are seeing some odd behavior with our app - we have two instances of our application running, and a single postgres app instance. We seem to have intermittent problems with database connections being held on to after deployments. We’re using Phoenix / Ecto and have our POOL_SIZE configured to 10. In this graph you can see each deployment is resulting in our connection count increasing by ~20 (20 → 40 → 60 → 80) and then we stop being able to check out new connections so our app breaks.

Any idea what’s up here? I’m assuming restarting the postgres server would fix but I want to keep it open for debugging since the connections are still pinned. All health checks are fine and the deploys completed succesfully.

EDIT: pg is actually showing status “critical” w/ “connect: connection refused”- the vm is healthy

Hey Kevin,

You may find the following conversations interesting:

Plus, I did note in a few comments in this forum that single instance pg isn’t supported, and that postgres-ha is the recommended way.

1 Like