MongoDB Atlas is the fully managed cloud database service — provisioning, patching, backups, monitoring, and scaling handled by MongoDB Inc. Most production deployments start here rather than self-hosting.

Why Atlas?

Self-Hosted Atlas
Manual provisioning and patching Automated infrastructure
DIY backup and restore Continuous cloud backups with point-in-time recovery
Custom monitoring setup Built-in metrics, alerts, Performance Advisor
Manual replica set management One-click scaling and version upgrades
Separate search infrastructure Atlas Search integrated

Atlas runs on AWS, GCP, and Azure in 100+ regions worldwide.

Getting Started

  1. Create account at cloud.mongodb.com
  2. Create a project (organizational unit for clusters, users, alerts)
  3. Build a cluster — start with M10+ for production (M0/M2/M5 are shared/dev tiers)
  # Install Atlas CLI
brew install mongodb-atlas-cli

# Login and create cluster
atlas auth login
atlas clusters create myCluster --provider AWS --region US_EAST_1 --tier M10
  

Cluster Tiers

Tier Use Case Storage Notes
M0 (Free) Learning, prototypes 512 MB Shared, no SLA
M2/M5 Development 2–5 GB Shared
M10+ Production 10+ GB Dedicated, replica set
M30+ High traffic 40+ GB Production workloads
M40+ Enterprise 80+ GB+ Multi-region, analytics nodes

Production minimum: M10 (dedicated resources, backup, SLA).

Network Access

IP Access List

Restrict connections to known IPs:

  atlas accessLists create --ip 203.0.113.50 --comment "Office"
atlas accessLists create --ip 10.0.0.0/8 --comment "VPC"
  

Atlas blocks all other IPs by default.

For production — no public internet traffic:

  Application (VPC) → VPC Peering / PrivateLink → Atlas Cluster
  
  # AWS VPC peering
atlas networks peering create aws --providerAccountId 123456789 \
  --vpcId vpc-abc123 --routeTableCidrBlock 10.0.0.0/16 \
  --region US_EAST_1
  

PrivateLink (AWS) and Private Service Connect (GCP) provide private connectivity without peering route table management.

Database Users

  atlas dbusers create admin --role atlasAdmin
atlas dbusers create appUser --role readWriteAnyDatabase
  

Use least-privilege roles — never atlasAdmin for applications:

Role Scope
readWrite@mydb Application user
read@mydb Analytics
dbAdmin@mydb Schema management

Connection string format:

  mongodb+srv://appUser:[email protected]/mydb?retryWrites=true&w=majority
  

Backups and Recovery

Atlas continuous cloud backup (M10+):

  • Continuous backup — oplog-based, point-in-time recovery
  • Snapshot schedule — daily, weekly, monthly retention
  • Restore — to same cluster, new cluster, or download
  # List snapshots
atlas backups snapshots list --clusterName myCluster

# Restore to new cluster
atlas backups restores create --clusterName myCluster \
  --snapshotId 67890 --deliveryType automated
  

Test restores quarterly — an untested backup is not a backup.

Monitoring and Alerts

Atlas provides built-in dashboards:

  • Operations — opcounters, connections, network I/O
  • Performance — slow queries, index suggestions (Performance Advisor)
  • Replication — lag, oplog window
  • Hardware — CPU, memory, disk I/O

Configure alerts:

  atlas alerts settings create --event REPLICA_SET_MIGRATED --enabled \
  --notificationType EMAIL --intervalMin 60
  

Key alerts to configure:

  • Replication lag > 60 seconds
  • Connections > 80% of limit
  • Disk usage > 80%
  • Query targeting scan-to-return ratio > 1000

Performance Advisor

Atlas analyzes slow queries and suggests indexes:

  • Review suggested indexes before creating — test impact on writes
  • Dismiss suggestions for one-off admin queries
  • Auto-create indexes with approval workflow (Enterprise)

Scaling Operations

Vertical Scaling

  atlas clusters update myCluster --tier M20
# Rolling upgrade — brief failover during election
  

Horizontal Scaling (Sharding)

Enable sharding on M30+ clusters:

  atlas clusters upgrade myCluster --enableSharding
  

Choose shard key before loading data — Atlas supports resharding but it is disruptive.

Read Scaling

Add analytics nodes (Dedicated) or enable Read Preference to secondaries:

  mongodb+srv://.../?readPreference=secondaryPreferred
  

Full-text search without Elasticsearch:

  // Create search index (Atlas UI or API)
{
  "mappings": {
    "dynamic": false,
    "fields": {
      "title": { "type": "string" },
      "body": { "type": "string" },
      "category": { "type": "stringFacet" }
    }
  }
}

// Query
db.articles.aggregate([
  {
    $search: {
      index: "articles_search",
      text: { query: "mongodb atlas", path: ["title", "body"] }
    }
  },
  { $limit: 20 }
])
  

Faceted search, autocomplete, and relevance scoring built in.

Atlas Triggers and Functions

Serverless event processing:

  • Database Triggers — react to insert/update/delete (like change streams, managed)
  • Scheduled Triggers — cron jobs
  • Functions — JavaScript serverless functions with MongoDB access

Use for cache invalidation, notifications, and lightweight ETL without managing consumers.

Multi-Region and Global Clusters

Global clusters (M30+) with zone sharding:

  US-East (default write) ←→ EU-West (local reads) ←→ AP-Southeast (local reads)
  

Data placed in geographic zones based on shard key — GDPR compliance and low-latency reads.

Atlas vs Self-Hosted Decision Matrix

Factor Choose Atlas Choose Self-Hosted
Team size Small/medium ops team Dedicated DBAs
Compliance Standard cloud compliance Air-gapped, special requirements
Cost at scale Higher per-GB Lower with reserved instances
Time to production Hours Days/weeks
Feature needs Search, triggers, charts Custom storage engines

Common Mistakes

  • Using M0/M2 for production — no SLA, shared resources
  • Allowing 0.0.0.0/0 in IP access list — open to internet
  • Not enabling backup on M10+ — data loss risk
  • Ignoring Performance Advisor suggestions for months
  • Scaling tier without investigating query performance first
  • Storing connection strings with credentials in source code

Troubleshooting

Connection timeout

  • Check IP access list includes your source IP
  • Verify VPC peering routes if using private connectivity
  • Test with mongosh "mongodb+srv://..."

Authentication failed

  • Verify username/password in Database Access (not Organization users)
  • Check authSource in connection string

Cluster auto-paused (M0)

  • Free tier pauses after 60 days inactivity — resume in Atlas UI

Production Checklist

  • M10+ dedicated cluster in production region
  • VPC peering or PrivateLink configured
  • IP access list restricted (no 0.0.0.0/0)
  • Least-privilege database users
  • Cloud backup enabled with tested restore
  • Alerts configured for lag, disk, connections
  • Connection string in secrets manager
  • Performance Advisor reviewed weekly

Best Practices

  1. Use separate Atlas projects for dev/staging/production
  2. Tag clusters for cost allocation
  3. Enable database auditing for compliance workloads
  4. Use mongodb+srv:// connection strings for automatic failover
  5. Plan cluster tier with 30% headroom for growth
  6. Review Atlas billing alerts monthly

What Comes Next

For workloads exceeding single replica set capacity, sharding deep dive covers shard key design, chunk management, and resharding strategies.