MongoDB Atlas Research & Analysis
Comprehensive research on MongoDB Atlas architecture, scaling, and AI workload optimization
MongoDB Atlas Research & Analysis
Purpose: Document all research findings regarding MongoDB Atlas architecture decisions for GoGrab Space AI infrastructure.
π Executive Summary
This document contains the complete research and analysis performed to determine the optimal MongoDB Atlas architecture for GoGrab Space, with specific focus on AI workloads including vector search, embeddings, and agent learning systems.
Key Decisions Made
| Decision | Choice | Confidence |
|---|---|---|
| Cluster Architecture | Single cluster with multiple databases | 98% |
| Production Tier | M30 (from Flex) | 100% |
| Search Nodes | Add when needed (not immediately) | 95% |
| Database Separation | 4 databases for different workloads | 95% |
ποΈ MongoDB Atlas Architecture Deep-Dive
How MongoDB Clusters Work
MongoDB Atlas clusters share resources at the node level:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MONGODB ATLAS CLUSTER β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SHARED RESOURCES (Per Node) β β
β β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β CPU β β RAM β β Storage β β IOPS β β β
β β β (shared) β β (shared) β β (shared) β β (shared) β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β
β ALL DATABASES COMPETE FOR THESE RESOURCES β
β β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β gograb-api β βai-agentsβ βgograb-ai β β gograb-analytics β β
β β β β β β β β β β
β β collections β β collections β β collections β β collections β β
β β indexes β β indexes β β indexes β β indexes β β
β β working set β β working set β β working set β β working set β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Resource Sharing Impact
| Resource | How It's Shared | Impact Level |
|---|---|---|
| RAM (WiredTiger Cache) | Single cache for ALL databases | β οΈ HIGH |
| CPU | Single thread pool | β οΈ MEDIUM |
| Storage IOPS | Single disk subsystem | β οΈ MEDIUM |
| Network | Shared connection pool | π‘ LOW |
| Indexes | Each loads into RAM | β οΈ HIGH |
The WiredTiger Cache Consideration
The WiredTiger storage engine maintains a cache that all databases share:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β RAM (e.g., 8GB on M30) β
β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β WiredTiger Cache (~50% of RAM) β β
β β β β
β β βββββββββββββββ βββββββββββββββββββββββββββββββββββ β β
β β β Core Data β β Vector Embeddings β β β
β β β (spaces, β β β β β
β β β widgets, β β Current: 987KB (25 docs) β β β
β β β themes) β β Future: Could grow to GB β β β
β β β β β β β β
β β βββββββββββββββ βββββββββββββββββββββββββββββββββββ β β
β β β β
β β If cache is full β DISK READS β 100x slower β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Cross-Database Query Analysis
Critical Finding: $lookup Limitations
MongoDB's $lookup aggregation stage does NOT work across databases:
// β THIS DOES NOT WORK!
db.getSiblingDB("ai-agents").agent_decisions.aggregate([
{
$lookup: {
from: "gograb-api.spaces", // DIFFERENT DATABASE - FAILS!
localField: "tenantId",
foreignField: "_id",
as: "space"
}
}
]);
// Error: $lookup from collection must be in the same database
Available Workarounds
| Method | Performance | Complexity | Best For |
|---|---|---|---|
| Application-level joins | Good | Medium | Most cases β |
| Data denormalization | Best | Low | Read-heavy |
| Atlas Data Lake | Slow | High | Analytics only |
| Change Streams sync | Good | High | Real-time sync |
Why This Matters for AI
Our AI system needs cross-database access:
| Core Data Needed | AI Usage | Frequency |
|---|---|---|
spaces |
Context for AI responses | Every request |
tenants |
Multi-tenant isolation | Every request |
widgets |
Widget generation context | Moderate |
modules |
Module generation context | Moderate |
themes |
Theme understanding | Low |
users |
Personalization | Every request |
Solution: Application-level joins with caching (same cluster, minimal latency)
π Cluster Tier Analysis
Flex Cluster (Current)
| Factor | Details |
|---|---|
| Cost | ~$35/month |
| Infrastructure | Shared hardware |
| Performance | Variable, unpredictable |
| Vector Indexes | Limited to 10 |
| Search Nodes | β Not available |
| Sharding | β Not available |
| Production Use | β Not recommended |
M10 Tier
| Factor | Details |
|---|---|
| Cost | ~$58/month |
| RAM | 1.7 GB |
| vCPU | 0.5 (burstable) |
| Performance | Burstable (may throttle) |
| Search Nodes | β Available |
| Production Use | β οΈ Low-traffic only |
M30 Tier (Recommended for Production)
| Factor | Details |
|---|---|
| Cost | ~$320/month |
| RAM | 8 GB |
| vCPU | 2 (dedicated) |
| Storage | 40 GB (auto-expand) |
| IOPS | 4,200 read/write |
| Connections | 3,000 max |
| Performance | Consistent, predictable |
| Search Nodes | β Available |
| Sharding | β Available |
| Production Use | β Recommended |
π Search Nodes Analysis
What Are Search Nodes?
Dedicated infrastructure for Atlas Search and Vector Search, separate from data nodes:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLUSTER WITH SEARCH NODES β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β DATA NODES (M30) β β
β β Primary βββββββ Secondary βββββββ Secondary β β
β β β’ Regular CRUD operations β β
β β β’ Standard queries β β
β β β’ NOT used for vector search β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β SEARCH NODES (S30) β β
β β Search Node 1 βββββββ Search Node 2 β β
β β β’ Vector search queries β β
β β β’ Atlas Search queries β β
β β β’ Completely isolated from data nodes β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Search Nodes Pricing
| Search Tier | vCPUs | RAM | Storage | Hourly | Monthly |
|---|---|---|---|---|---|
| S20 | 2 | 4 GB | 100 GB | $0.13 | ~$95 |
| S30 | 4 | 8 GB | 200 GB | $0.24 | ~$175 |
| S40 | 8 | 16 GB | 380 GB | $0.46 | ~$335 |
| S50 | 16 | 32 GB | 760 GB | $0.91 | ~$665 |
Note: Minimum 2 Search Nodes required when enabled.
When to Add Search Nodes
| Trigger | Threshold |
|---|---|
| Vector search latency | > 100ms consistently |
| Embeddings count | > 500K documents |
| Database operations slowing | During AI workloads |
| Memory pressure | > 80% utilization |
π Single Cluster vs Separate Clusters
Detailed Comparison
| Factor | Same Cluster | Separate Clusters |
|---|---|---|
| Monthly Cost | $320 (M30) | $640+ (2Γ M30) |
| Cross-DB queries | β Fast (2-5ms) | β οΈ Slow (10-20ms) |
| Fault isolation | β οΈ Shared | β Independent |
| Scaling | Together | Independent |
| Management | Simple | Complex |
| Connection strings | 1 | 2 |
| Backups | Unified | Separate |
Why We Chose Single Cluster
- Cross-reference needs - AI needs tenant/space data constantly
- Search Nodes - Solve isolation problem within single cluster
- Cost efficiency - No need to double infrastructure
- Simpler operations - One cluster to manage
- Current scale - 25 embeddings, 987KB (nowhere near limits)
π Scaling Strategies (Within Single Cluster)
Vector Quantization
Reduces memory footprint dramatically:
| Quantization | Memory Reduction | Accuracy Impact |
|---|---|---|
| float32 (default) | 0% | Perfect |
| int8 (scalar) | 75% | ~1% loss |
| int1 (binary) | 97% | ~5% loss |
Example Impact:
1 Million Embeddings (1536 dimensions each)
float32: 6.14 GB RAM needed
int8: 1.54 GB RAM needed (75% savings!)
int1: 192 MB RAM needed (97% savings!)
Sharding (M30+)
Distributes data across multiple shards while maintaining:
- β Same connection string
- β Same databases
- β Cross-database access (application-level)
- β Transparent query routing
Tiered Storage
HOT TIER (in RAM) β Recent 30 days, high-value patterns
WARM TIER (SSD) β Last 6 months, queried on demand
COLD TIER (Archive) β 1+ year, compliance retention
π° Cost Optimization Path
| Phase | Tier | Monthly Cost | When |
|---|---|---|---|
| Development | Flex | ~$35 | Now |
| Pre-launch | M10 | ~$58 | Optional testing |
| Production Launch | M30 | ~$320 | At launch |
| Growth | M30 + 2ΓS30 | ~$670 | When needed |
| Scale | M50 + Sharding | ~$1,500+ | Future |
π Sources & References
- MongoDB Atlas Documentation: atlas.mongodb.com/docs
- Vector Search Best Practices: mongodb.com/vector-search
- Search Nodes Documentation: mongodb.com/search-nodes
- Pricing Calculator: mongodb.com/pricing
π Related Documentation
- Architectural Changes - What changes and why
- New Architecture - Target architecture design
- Backend AI API Plan - Implementation plan