As a MongoDB Community Leader, the multi-tenancy question is one I get asked about regularly, usually at one of two moments: when a startup is designing its first schema, or when its largest customer has started to slow everyone else down. The right answer depends on the tenant, not just the product.
The three main patterns
| Pattern | Isolation | Cost and operations | Good for |
|---|---|---|---|
Shared collection with tenant_id | Logical, enforced in application and queries | Cheapest; one set of indexes | Most tenants of most SaaS products |
| Database per tenant | Stronger; separate namespaces and access rules | More indexes and operational overhead | Mid-sized tenants with specific needs |
| Cluster or project per tenant | Strongest, including network and resources | Most expensive | Large or regulated tenants, data residency |
MongoDB's Search and Vector Search documentation recommends the shared-collection approach for most workloads, with a tenant identifier on every document and a single index serving all tenants12.
The pattern to avoid
A collection per tenant feels like a neat compromise. The documentation advises against it: for Search it cites issues such as increased replication lag and resource contention, and it notes that isolation guarantees apply at the database level, so separate collections in the same database add no isolation benefit1. You pay the operational cost of many collections and get none of the isolation.
Making the shared collection safe
Logical isolation is only as strong as its enforcement. The controls I put in place:
- Tenant ID in every index, as the leading field where queries filter by tenant, so tenant-scoped queries stay fast and selective.
- One data-access layer that adds the tenant filter to every query automatically. Developers should not be able to forget it.
- Tests that try cross-tenant reads on every release, including through search and aggregation paths.
- Search and vector indexes filtered by tenant, so retrieval for an AI feature can never return another customer's documents. This is the same rule as in hybrid search for RAG, applied at the tenant level.
- Per-tenant metrics for query volume and latency, so a noisy tenant is visible before it hurts others.
The hybrid most SaaS platforms end up with
In practice, I usually design for a hybrid from the start: the long tail of tenants shares a collection, while a small number of large or regulated tenants move to dedicated databases or clusters. The trick is making that move cheap:
- Route every request through a tenant directory that says where each tenant's data lives.
- Keep the schema identical across shared and dedicated placements.
- Build and rehearse a migration path for moving a tenant, including its search and vector indexes.
On sharded clusters, MongoDB's documentation also covers moving busy collections between shards when tenants have their own databases, which helps balance load4. The general Atlas guidance on building multi-tenant architectures is worth reading alongside the search-specific pages, since the trade-offs differ3.
Design the tenant directory on day one, even if every tenant starts in the shared collection. It is the difference between a one-day migration and a three-month project when your biggest customer asks for dedicated infrastructure.
Isolation questions buyers will ask
Enterprise and regulated buyers increasingly ask where their data lives and how it is separated. Have clear answers for data residency, encryption and access control per tenant, ideally backed by controls you can evidence, as in SOC 2 for AI and SaaS startups. For buyers in the Gulf, residency often means a dedicated in-country placement, which the hybrid model handles cleanly.
How I can help
I design MongoDB data models and multi-tenant architectures for SaaS and AI products, and review existing ones before they become painful. As a fractional CTO I can own the data roadmap. Or analyse your challenge and bring the result to a call.
- 1Multi-tenant architecture (MongoDB Search)MongoDB documentation
- 2Multi-tenant architecture (MongoDB Vector Search)MongoDB documentation
- 3Build a multi-tenant architectureMongoDB Atlas documentation
- 4Moveable collections: multi-tenantMongoDB documentation