Given (in the future, not at present):

  • 100 multi-tenant microservices
  • 5000 customers (or tenants)
  • each microservice must be able to store data per tenant
  • data is managed in relational databases, because ACID transactions are required (for whatever reasons)
    • I fully realize the scaling limitation of such databases. Let us assume that the per tenant data volume as well as request intensity does not warrant advanced scaling requirements.
  • Azure cloud (it is what it is :-()

From these I make the following conclusions:

  1. Database per tenant.

    Although we assume that per tenant data volume and request intensity does not warrant advanced scaling, if more than one tenant is "stuffed" into a single database that assumption may no longer be true.

  2. N databases per DB server

    Theoretically, DB servers may hold thousands of databases. However, we want to minimize the amount of downed tenants if "fit hits the shan". Hence N would not be thousands. But probably tens.

  3. Each DB server has dedicated microservice deployment associated only with it

    This way the DB server X may serve requests from the microservice A of version 1 and the DB server Y may serve requests from the microservice A of version 2. The DB schema may be different between these versions.

So these conclusions lead to multiple questions:

  1. What is N?
    • 50 ?
    • 100 ?
  2. What database to use?
    • Azure Database for PostgreSQL
    • Azure Database for MySQL
    • Azure SQL Database
  3. 5000/N DB servers to cover all the tenants for one microservice. For 100 microservices it results in 500,000/N DB servers. E.g.:
    • N = 50 --> 10,000 DB servers (deployments)
    • N = 100 --> 5,000 DB servers (deployments)

This is a lot of DB servers and a lot of microservice deployments. Suppose each deployment requires 2 web server nodes. That means 20,000 (or 10,000) web server nodes! When adding geo redundancy this translates to doubling the number of web server nodes as well as DB servers (to be able to failover to another region). This is crazy amount of DB servers and web server nodes.

Am I wrong at the core with some of my assumptions? What am I missing?

  • Are you E-R models designed to support multi-tenant or the microservice is in charge of switch between different databases on the same database server?
    – JRichardsz
    May 28, 2022 at 16:54
  • I am unfamiliar with the term "E-R models". We have a dedicated Identity Service . When the client code wants to talk to a micro service it passes it the previously acquired authentication token which contains the tenant id. It is then becomes the micro service responsibility to resolve it to the respective tenant context, which would contain the DB connection string. Nothing in this design requires the databases to reside on the same DB server. And indeed, today some deployments are served by tens of DB servers containing hundreds of tenant DBs. But we have just a few micro services for now.
    – mark
    May 30, 2022 at 14:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.