Next.js Discord

Discord Forum

Scalability and MongoDB Connection Management for Multi-Tenant Architecture

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
I'm working on a backend service where the requirements are as follows:

For each user, a unique MongoDB connection is created.

The client provides a domain like client1.builder.com, and our backend checks if this domain exists. If not, it allows the user to proceed.

The backend then connects to the unique MongoDB for each client when they revisit and retrieves data specific to that client's users.

Now, my main concern is scalability. Suppose 1,000 users come in at the same time. Can my backend service handle and establish individual MongoDB connections for each of them, or would this approach be unfeasible due to the number of concurrent database connections?

Would it be better to use a single MongoDB with a tenant-based approach (like using a single database with separate collections per client)? Or is the per-client unique DB approach viable with enough resources?

Looking for suggestions on how best to approach this while maintaining scalability.

Thanks!

0 Replies