We are now in a process of migrating our server-per-client architecture to a multi-tenancy architecture. Everything is in place except for one design issue we are having.
We are using a subdomain in order to determine what tenant it is and route it to the proper DB (it is DB-per-tenant).
Let's say we have a tenant class with the following fields:
- DB Connection string
The question is how to save the tenant's data, it sounds like a simple question, but the problem is that each service will need to access that tenants list, as it happens in each request it needs to be fast and reliable. Keep in mind, most services are not on the same machine. We thought about the following options and I'll appreciate getting your opinion (especially if it is based on your experience):
- JSON File - All the tenants will be saved in a JSON file. The advantage is that it is very simple and fast. But, as this file can't be accessed through all the services it makes it not relevant for us.
- API - We will have another service that will hold all the tenants and will expose REST/GRPC API for getting the tenants list. The problem with it is that will require making a request on each incoming request which will cause performance issues. Caching might be a problem as this is critical information.
- Slave Caching - We will have a centralized service that will hold all the tenant's information. We will also have on each service an API (and storage) for getting the Tenants list. On each Tenant creation or edit on the main service, it will update all the depending services. The problem here is that it adds more overhead as we will need to create the same API in all of the services and register them.
- Shared DB - One centralized service to manage all the tenants, but the tenant's table/DB will be exposed to all of the other services so they will be able to query it directly. The problem I see here is performance as that DB will be a buttle neck for our entire platform as every request will have to query it.
- Master caching - Each service will have its own tenants list. On a new request, it will look for the tenant, if it can't find it, it will look for it in the tenant's service and will add it to the local list. The problem here is on editing a tenant. We will probably need to update all the depending services and therefore it makes more sense to use the Slave-Caching approach.
Am I missing other ways?
Thanks in advance, Shaul