Hybrid-tenancy with MongoDB in .NET API — Part 01

Alex Alves
2 min readDec 8, 2020

Many times we have some situations that require our application to attend to many clients. In this context, we have some techniques to attend this, but we will talk about three architectural strategies:

Single-Tenant

This technique consists of providing all of the new infrastructure necessary to stand-up an application. So, this signifies that you create a new instance of applications, a new database, and all other necessary things.

Clearly, you can note that the new client wins a new and completely isolated application. But the cost to keep this is high, besides that, you have some difficulty to deploy this application, like to construct a pipeline of CI/CD.

Multi-Tenant

In this technique, all clients use the same application and the same database, but you can separate the logic by schema and/or using Foreign Keys. In this case, the volume of data in the database can be grown a lot, and the risk to share/leak out the same data is high too.

Hybrid-Tenant

This is, maybe, the best alternative. This technique uses the same application but uses a different database, according to the client. So, the risk to share/leak out the data is less than the previous technique, and it is possible to do a horizontal scale.

What do you need to evaluate?

According to Fernando Neiva Paiva in his article about the tenants, we think about seven points:

  • Security policy
  • Budget
  • Scalability and elasticity
  • Functional requirements
  • Operations
  • Customizations

For the next step, we will see how can we build an application to apply this technique!

See you later!

Go to Part 02

--

--

Alex Alves

Bachelor in Computer Science, MBA in Software Architecture and .NET Developer.