We are currently in process of designing a Multi tenant application, we choose to go with Mongo db for data storage. Our application needs to store different entities, like user, employee, payroll etc., We want to build a scalable platform where clients can onboard/offboard faster, and manage the solutions easily. We also wanted to isolate the customer data logically.
We are discussing few options on Mongo db how to place the data -
- Separate database per client, each collection stores different group of documents from application.
- Separate collection per client in a database, all data for a particular client stored in a single collection each document segregated using petitioning.
Few queries -
- Please suggest me which is the best approach to go ahead. Is one database per client or one collection per client. Or any other feature which can logically segregate the data still achieve better performance.
- In one collection per client approach - When all data related to a particular client stored in one collection, does it create any performance issue during CRUD operations?
- In one collection per client approach - Can the data queryable using partition key and the id of the document, so it will be faster retrieval.
- In one collection per client approach - Does the collections are isolated behind as logical separation?