I’m working on a SaaS product and I’m planning to use MongoDB with 1 DB per tenant for security and clean data modeling per tenant.
The DBs should be hosted on my own VPS - if load / data growth is increasing, I’m fine with (virtual) vertical scaling and even horizontal scaling.
For a standard tenant DB I assume:
Collections in the dozens
Records per collection in the hundreds or thousands - max. millions
Records with a few KB size max.
Mostly writes, no real time, maybe a few connections per minute max. Nothing really demanding.
Version history in separat version collections
To get more specific, what are the implications on servers with a few dozen, hundreds and then thousands tenants in terms of:
Storage: I’ve read some odd things about WiredTiger with fixed file sizes for multiple DBs or is 1 DB ca. as big as it’s contents
Performance / RAM: I assume 1 DB per tenant is demanding a bit of RAM
Reliability: What’s the first one I should do, to have a replica or similar, so that I’d reduce downtime?
Anything else to pay attention to, apart from the standard setup (change port, use proper roles / passwords, etc)?
Sorry … of course documents. I thought about the source systems here.
That would probably be a great problem to have - 10000 paying customers
My idea here would be, after ca. 6 - 9k database, I’d simply create a new / separate server, if that would be an easy solution?
But really … great problem to have and nowhere close to by now.
Thanks for the hints on the replica set. Then I take this into consideration during the planning phase already.
With Atlas it is trivial. With physical servers it is another story. With AWS or GCP easier that physical but harder than Atlas and potentially more expensive.
I do not have any thing else to add more that I only saw recommendations against one database per customer.