Ecto connection management during deployments (via Gigalixir)

My current setup is a single replica application on Gigalixir talking to a custom Google CloudSQL postgres instance (since I have free credits to use).

Google say there are 25 connections for my instance size, but 6 are “reserved”, so I set ecto to use 19 connections. Everything goes great until I try and deploy. There will be two instances of the app running for about 30 seconds and during this period the newer of the two keeps failing with connection errors. Only when the old one gets terminated does everything go back to normal.

The only solution I have found at the moment is to set my connection pool to 9. This makes the rolling deploys smooth, but just feels a little wasteful.

Any tips on how this has been solved elsewhere?

Thanks for reading!

Hey @amarraja, I think what you’re doing is the best option I can think of. Short of upgrading your instance as described here: https://stackoverflow.com/questions/51084907/how-to-increase-the-connection-limit-for-the-google-cloud-sql-postgres-database

It seems wasteful, but I don’t think there is a better option.

Thanks @jesse, makes sense. Am I right in thinking I would have to do the same thing when using the Gigalixir provisioned databases too?

Current setup is fine for my immediate needs - if it becomes a problem, then it would be a good problem to have!

Yup definitely. Lemme know if you run into any problems!

1 Like