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

  1. Cross-reference needs - AI needs tenant/space data constantly
  2. Search Nodes - Solve isolation problem within single cluster
  3. Cost efficiency - No need to double infrastructure
  4. Simpler operations - One cluster to manage
  5. 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:

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


πŸ”— Related Documentation