Question

Managed PostgreSQL: Handling Multi-Tenancy

Posted October 12, 2020 451 views
Databases

My frontend and backend are hosted as serverless functions on Vercel. I am using a multi-tenancy approach, where every client get’s it’s own database. This means however, that I run out of connections pretty quickly, because AFAIK you need a new connection for each database. I am thinking to switch to digital ocean, because of the managed connection pooling, which should decrease the amount of connections needed for each database and I guess I could setup the connection pool via the API for each new database. However there is still the hard limit of connections.

My question is if my assumptions are right, or how I should go about the database topic with my use case and if there is a possibility to increase the max_connections of my psql db

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

Hi @devFish,

PgBouncer pool connections are currently limited to 20 per database. If you require more PgBouncer pool connections than this you will need to contact DO support.

https://docs.digitalocean.com/support/

And for Postgres managed database, the connection limit is set depending upon the size of the database cluster.

For example: If you have a 1 GB RAM cluster it will get 25 backend connections and 3 connections will be reserved for maintenance; so the available backend connection that you will get is 22.

For more information on Postgres managed database limitation check the below article :

https://docs.digitalocean.com/products/databases/postgresql/#postgresql-limits

I hope this helps!

Regards,
Rajkishore