I am explaining my use case –
I need to create a Shared Cluster on our product’s free tier (a single cluster shared by every user, where each user is 1 client). Therefore we can have a single cluster for 1000 clients / users.
We will be limiting the number of collections / data size per each user (with application code).
Our requirement is that each user should be able to see their data stored in this cluster (and only their own data). Creating 1 DB user per Client should ideally work, limiting them to a logical database (1db per client).
Atlas says it can create only 100 Database Users, whereas we can use
db.createUser() command to create a db user internally also.
Any help on how we can scale this to 1000 or 10000 users who would want to connect to this cluster via Compass/Shell on their own?
I read this article but could not find any answer…
Or any other solution?
Regarding the limit, as per the Atlas MongoDB users documentation, you’ll probably need to contact Atlas support team to discuss whether this is possible or not for your use case / project:
Atlas supports a maximum of 100 database users per Atlas project. If you require more than 100 database users on a project, contact Atlas support.
There are further details including considerations and benefits on this type of Multi-Tenant Architecture on Atlas described in the linked documentation.
Please note that the Database User limitation is meant to curtail the unbounded growth of users. Generally, I have also seen that the majority of Atlas projects uses less than 100 database users for a given project.
Whether or not the database limit can or cannot be increased for your specific Atlas project(s), we strongly caution against a system which requires hundreds of database users, as this generates significant management and coordination overhead, as well as the potential to require significant redesign if the scale of your growth is unchecked in this area. We strongly recommend abstracting authentication at a higher level.
In saying so, you may be interested in using an LDAP server for user management and integrate it with the Atlas project. Please note that the LDAP integration with Atlas is currently only available for M10 or higher tier clusters and is not supported/available for M0,M2,M5 and serverless instances. Alternatively, you could separate clusters into different projects, provided this is applicable to your use case.