I'm researching if MongoDB is the solution for my problem of storing schema-less data for multiple users. Let me sketch the problem: I've got a lot of users (100k) and want to have some place for these users to store data. Now I can create some kind of proxy that will do the RBAC for me and filter data based on some property in the database, but I wonder if MongoDB can do this for me.

I cannot seem to find any limitations on the documentation page of MongoDB that there are limits of how many users+roles+collections there can be on one MongoDB server (preferably a cluster).

At the moment I'm thinking of a structure where every user has a access to a single collection. I can put these collections into a single database and then give the user a role that only has readWrite access to a single collection.

This would mean that the database would exist of 100k collections that each have 1 role with 1 user.

Is this a feasible structure and would this scale/perform well?

If I would chose for the proxy solution then I would let my proxy filter the data based on who requests it. That would result in a data structure like the one below:

  _id: ObjectID(),
  customerId: "some customer id",
  data: {}
  • 1
    Technically it should be no problem, see MongoDB upgrade cannot be done in hours where it has a million collection. However, just because it is possible, it is not automatically the preferred way of doing it. Jun 27 at 12:12
  • I've talked with MongoDB and they say also it's technically possible, but they don't recommend it because of the management of users would be difficult. But as we would automate the creation/deletion of users, this would not be a problem. Jun 27 at 12:32
  • Agree, but you may consider to use only one collection and control the access at application level. Jun 27 at 12:48
  • That's indeed on our list of considerations, though that would mean that we are going to proxy all the data through our application, and giving the user direct access to only one collection did sound very attractive. Jun 27 at 13:20
  • Just a note, you can also provide direct read/only access by creating a view for each user and grant according select privilege to it. Jun 27 at 13:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.