N
Neon2y ago
optimistic-gold

Best way for Schema/Database per tenant?

Hello, my SaaS project will require a separate database (or schema) for each tenant. (Each trial registration would create a new database). From what I've read it looks like Neon should be able to support this model. But I am not completely sure it is a good idea. I am wondering, at what level should I separate my tenants by? A project per tenant? A branch per tenant? A database per tenant all within a single branch in a single project? Or a database per tenant within multiple branches in multiple projects? I understand that Computes are each mapped to a branch in a project. So having multiple branches can help with distributing load. How easy is it though to move a database to a different branch or different project in case I need to move some high use tenants out of a branch? Or is all of this a bad idea?
2 Replies
optimistic-gold
optimistic-goldOP2y ago
Currently, looking at the Pricing page, since there are limits to the number of Projects and the number of Branches per project, then having multiple databases in multiple branches in multiple projects seems to be the correct answer. And then moving any tenants that need more compute out to less crowded branches. How many tenant databases would I be able to run in a single branch though. Just thinking ahead about scaling, if I do 1 database per tenant, then I will need 1 connection per tenant right? In that case if I have more than 10,000 active tenants then I could hit the 10,000 max concurrent connections limit? Then it might be better to do 1 schema per tenant? How many schemas per database, and databases per branch (compute) should I expect to be able to support?
deep-jade
deep-jade2y ago
I believe we are recommending a project per tenant. If you are worried about pricing, talking to our Sales team is a good place to start!

Did you find this page helpful?