Julio Borges
Julio Borges

Reputation: 662

Web API structure for multiple clients [Multitenancy]

I have the following situation:

I have a Web application that accesses the data through a C # WebAPI. I need to apply the concept of multitenancy in it so that my application is accessed by multiple clients and that each client accesses their database individually.

Faced with this need, I researched the StackOverflow Portuguese and found the following questions:

Web application for multiple people

Databases for different clients

As for the concept I understood, however my question is about the deploy of my WebAPI and what would be the best practice:

Should I deploy and host a single API instance in IIS (and redirect access to the database via code)?

Or should I perform the individual Deploy, that is, host numerous instances of the API in IIS, each one accessing your database?

If the second option is the most feasible, is there any way to do this multiple deploy in a more automated way? Is there any cloud feature that enables this deploy escalation (Azure, Amazon, etc ...)?

Upvotes: 1

Views: 1176

Answers (1)

Saravanan
Saravanan

Reputation: 7844

Couple of points:

  1. You can use the single app that is placed behind the load balancer.
  2. For each request, you identify the tenant from the authorization headers.
  3. Based on the identification, the database shard can be selected, so database isolation is achieved
  4. Having a single instance helps in easy upgrades and issue fixes/ deployment.
  5. In case you opt for database shard, review the Azure shard map.

HTH

Upvotes: 2

Related Questions