HACKER Q&A
📣 chirau

How to scale or rearchitect a single portal site to a multi-tenant SaaS


I don't even know if I worded that title correctly but here is my case in simple English.

I built a site for a school to manage their alumni association. So it's a complete site with a dashboard that exists at say example.com where they can create new campaigns, add pictures, add news posts etc. After a while, some other schools also wanted the same portal as I built for the one school. I don't know how many more will want this kind of site, but many more will it seems. So instead of building out each site individually, I want to build a SaaS of sorts. So that each school can sign up and spin up it's own such alumni association site. All the portals will be accessible from one TLD, so the url will be something like example.com/school1 or school1.example.com.

I have never built something like this, so I have several questions:

1) I'm guessing I can use the site I have as a template to spin off new sites in the new SaaS?

2) What is the correct term for this multi-tenant setup so that I know how to speak when I ask questions or do consultations?

3) What resources can I use to learn to build such a multi-tenant infrastructure? I have not seen any literature on such indulgences. I'm looking for books, blog posts, tutorials etc on architecting such kind of software or something close.

4) What technologies am I looking at utilizing to build out such and what expertise should I be looking for? Is this what stuff like Docker/Kubernetes/containerization is used for in isolating stuff? Or I should be looking at something else?

5) What are some potential pitfalls and points of concern that are unique to this endeavor that I should keep in mind when planning this out?


  👤 mooreds Accepted Answer ✓
Haha, I'm working on a multi tenant guide for my employer (an identity provider), which will at least cover the login/logout/registration behavior.

> What is the correct term for this multi-tenant setup

Private label, white label.

> I can use the site I have as a template to spin off new sites in the new SaaS?

Do you want to update the application to handle multiple tenants? You could also spin up an entirely separate physical application (a new WAR file, if you were building it in java). But this is simpler to start, but will lead to complexity in the end, as you will have to deploy to N sep instances on update.

> What technologies am I looking at utilizing to build out such

Any tech can do it. Here's the example app I'm building in PHP: https://github.com/FusionAuth/fusionauth-example-symfony-mul...


👤 aliasEli
Like several commenters pointed out, using separate systems seems the best approach for the short term.

I suggest that you first implement the system for multiple schools before re-architecting your system. Your will have better understanding about which parts of the system should be customizable and which ones should not.

Do not attempt to make your system overly customizable. I have seen several systems where almost everything could be customized. In most cases these were pretty complicated to use, and of when the customer came with some request we had to change the customization code itself, because the request could not be satisfied with a change in customization parameters.


👤 pricci
One solution would be to dockerize your current setup and then spin a container for each school.

Then with nginx, point example.com/school1 to its corresponding container.


👤 biermic
You'd create a table that holds the different tenants. Then add a association between users and tenants. Store the tenant in the authenticated users session.

Then you could attach the tenant specific configuration to the session too, or better keep it in an in-memory cache.


👤 aww_dang
Depends on the tech stack you want to work with. What you are describing is often called "white label".

The simple way to build this would be to store each customer's data in a database.