N
Neon7mo ago
rare-sapphire

Multi Tenant b2b saas

Pros and Con's of one project with many branches (one branch per tenant) VS multiple projects (each tenant gets their own project with one db branch)
13 Replies
relaxed-coral
relaxed-coral7mo ago
We generally recommend a project per tenant. This keeps their resources isolated. https://neon.tech/use-cases/database-per-tenant#one-project-per-customer
Neon
Database Per User at Scale
Manage thousands of Postgres databases with minimal effort and costs.
rival-black
rival-black7mo ago
I do have the same question. Aren't the resources saparate for multiple branches too. What I mean, noisy neighbors shouldn't be a problem, because every branch has it's own autoscaling setting, right?
relaxed-coral
relaxed-coral7mo ago
That's true. Each branch has its own compute, for which you can set autoscaling. This doc provides a diagram showing the Neon object hierarchy: https://neon.tech/docs/manage/overview
Neon
Overview of the Neon object hierarchy - Neon Docs
Managing your Neon project requires an understanding of the Neon object hierarchy. The following diagram shows how objects in Neon are related. See below for a description of each object. Neon account...
other-emerald
other-emerald7mo ago
If I ran a project per tenant how would one manage all the db connections in a backend stack? Seems like a lot of pools would have to be kicking around to distribute out requests to any one of hundreds of connection strings on a per request basis?
rival-black
rival-black7mo ago
So i guess the only benefit of using a project per tenant instead of branch per tenant is, that the tenant can choose a region. Otherwise since branches can be nested deeply, I don’t see any other reason to opt for a project per tenant setup. I need to initiate the client per request anyways, since running from a Cloudflare worker, so i don’t have a lot of idling connection. However for a long lived server it might be different, I can imagine
relaxed-coral
relaxed-coral7mo ago
There are certain project-level settings you might want to consider such as the history retention setting. For example, will some tenants want a longer point-in-time recovery setting, or will you be granting tenants access to the Neon console.
No description
relaxed-coral
relaxed-coral7mo ago
You can also track usage at a project level. Some of these things you can track at a branch level too, such as Compute.
No description
rival-black
rival-black7mo ago
That’s good points. I really wish that the Launch plan would give also 5000 projects so that the possible amount of branches and projects are synced. Or at least allow to pay a price per project over the limit, but it is a big jump in price, just because I need one project more
evident-indigo
evident-indigo7mo ago
Although I don't see paying extra per 1 additional project happening, if you move from the Launch plan to "Scale" you get 1000 projects + the ability to pay for additional projects in batches of 1000 after that. If you are able to of course.
automatic-azure
automatic-azure7mo ago
Last part is that our APIs allow you to pull the per-project usage so you can bill tenants accurately for their usage. We don't have that for branching and don't have immediately plans for it either.
rival-black
rival-black7mo ago
Well if I have 1001 projects I need to pay for 2000. even if half of the projects are idle or unused. But even that is not my issue. My concern is that if I have 99 projects, I can split the cost for the launch plan across all of them: 0,19USD per tenant/month. However if i have 101 projects, I would need to bill clients 0,68USD per tenant/month. For sure if we talk about 999 projects, it would be 0,06USD per tenant/month. But again I'm talking about the low end of the higher tier. Maybe it could be possible to pay a overusage price for projects / month, similar to storage?
quickest-silver
quickest-silver6mo ago
hmm if you do project per tenant, the project limit is pretty low tho (100 on launch plan) - so you can really only support 100 tenants. Even the business plan only supports up to 5000 projects, which seems pretty low. this doesn't seem viable if my app has a freemium plan - i'd reach the limit pretty quick. any suggestions?
relaxed-coral
relaxed-coral6mo ago
Hi @etcher if you're working at those numbers, I'd suggest reaching out to our team here and discussing something custom to fit your use case: https://neon.tech/partners
Neon
Accelerate your business with Neon partnership — Neon
Bring familiar, reliable and scalable Postgres experience to your customers.

Did you find this page helpful?