Multi Tenant Application using Node.js + Mongo DB

I am planning to create an app which will have a unique database for each client. I want to divert the api request to specific client database based on the sub domain from which the request has been made. How should I handle the database connections for each request?

Hi @Adhiraj_Kinlekar ,

The problem with a database per tenant approach is it might create the too many collections anti pattern .

When there are a large number of collection it impacts the performance and sometimes the recovery time of clusters.

If you are using Atlas , why not to consider usage of realm applications and Realm api keys as tenants classifiers. Then you will be able to use realm rules to allow only tenant owners to view their data.


Hi @Pavel_Duchovny, thank you for your response. I will start looking into this approach.