Hello,
I’m designing a multi-tenant database for a SaaS application. Each tenant gets their own NextJS application which is hosted in Vercel. All of these NextJS applications can have up to hundreds of concurrent users. This causes a connection limit problem.
How should I design the database so that there won’t be too many simultaneous connections? My initial plan was to use a single ServerlessCluster in which each tenant would get their own database containing relevant data coming mainly from the NextJS application’s users. The problem with this approach seems to be that the ServerlessCluster has a limit of 500 simultaneous connections, which basically means that there cannot be even 500 concurrent users interacting with the NextJS applications. I don’t expect more than 20 tenants, which means that the peak connections should not get over 4000 as 500 connections per tenant concurrently is likely to be enough.
I’ve tried to look into connection pooling, but I haven’t figured a way to make it work with many different databases. So, in short: how can this connection limit problem be solved?
- Teemu