DEV Community

Buğra Gündüz
Buğra Gündüz

Posted on

How do you manage multiple customers in a SaaS?

I have been trying to start an analytics SaaS. I'm completely new to this kind of architecture, and saw that there is a huge debate online about multi-tenancy vs single-tenancy. Which one do you prefer, why, and how do you implement it? Since it's an analytics service, I am leaning towards creating a database for each customer for the added privacy.

Top comments (5)

Collapse
 
kant312 profile image
Quentin Delcourt

The solution I've seen the most is to have a "landlord" database and one "tenant" database per client. The landlord DB acts as a kind of router to select the tenant DB, based for example on the subdomain being used.

This allows for better scalability, isolates sensible information between clients and simplifies the queries as you don't need to specify the tenant name for every SQL operation.

Going this way directly is not premature optimization I think. If you go the single DB route directly it becomes difficult to refactor to a multitenancy later on.

This is not the only way to implement such a system of course. There is a good podcast covering the subject here:
fullstackradio.com/episodes/80

Collapse
 
pavelloz profile image
Paweł Kowalski • Edited

This sounds kind of like a load balancer :)

Collapse
 
kant312 profile image
Quentin Delcourt

Indeed, they both are layers of indirection 🙂

Collapse
 
brandinchiu profile image
Brandin Chiu

Honestly, the data, and what you plan on using it for plays a pretty big role in your decision.

Generally, my rule of thumb is to use an isolated, multi-tenancy model whenever my clients have their own data of their own customers.

The biggest reason is that it does a better job of eliminating the possibility of data from one client bleeding into another.

However, what does that data mean to you?

Especially in the analytics space, there might be a benefit of having all of the data in once place for simplicity, as your own analytics systems can make use of data from multiple clients to make suggestions.

If you have 10 different clients with similar businesses, they would all benefit from analytical patterns that you could find easier with all of that data being in one place, rather than having each one rely only on their own data sets.

(obviously you can work around this with a multi-tenancy design too, but it's easier on a single storage solution).

There isn't a perfect solution to this question -- there will be tradeoffs either way. You simply need to decide which of those pros and cons are worth exploring for your own business.

Collapse
 
aronjohnson profile image
Aron Johnson

AWS has some good resources about multi-tenancy and tenant isolation. What to consider, different possible architectures, etc.

I realize you are asking about multi-tenancy vs single-tenancy, and these resources are more about different types of multi-tenancy, but they still should offer lots for you to consider. Many of the concepts should be applicable even if you are not building on AWS.