Chili Pepper Design

Web development relleno

Multi-tenant MongoDb

| Comments

Concerns: Right now we are handling our data multi-tenancy with a shared-schema approach, using application level security by enforcing user_id filters on all data queries. Ideally it would be nice if MongoDb could enforce some of our multi-tenant security concerns, but your options are a little limited with Mongo right now. You can create separate Mongo databases for each tenant, which makes it simple to using Mongo’s authentication on data. However it’s only recommended to host about 200 unique databases under a single Mongo process, and even with the smallfiles option the way Mongo allocates space for databases they take up a minimum of 32MB each (doubling in size as more data is added), leading to some large disk usage. Another option is using collections for each tenant. The default MongoDb settings limit the number of collections in a database to 24,000, but by increasing the size of the namespace file you can go to ~3 million ( of Namespaces

We have not begun to approach data mass where we need to shard, I’ll be sure to write a blog post about our experience sharding when we cross that bridge.