MongoDB Atlas
MongoDB Atlas is the fully managed cloud database service built by the same team that builds MongoDB. It handles provisioning, setup, patching, backups, and monitoring — letting you focus on your application rather than database operations.
Atlas vs Self-Hosted
Feature | Atlas | Self-Hosted |
|---|---|---|
Setup Time | Minutes | Hours |
Backups | Automatic | Manual |
Monitoring | Built-in dashboard | DIY (ops team) |
Scaling | 1-click vertical and horizontal | Manual reconfiguration |
Cost | Pay-as-you-go | Server + ops cost |
Free Tier | M0 — 512 MB shared | N/A |
Creating a Free Cluster
Go to cloud.mongodb.com
Create a free account or sign in
Click "New Project" and give it a name
Click "Build a Database"
Choose M0 Free tier
Select a cloud provider (AWS, GCP, or Azure) and region closest to you
Give your cluster a name
Click "Create"
Security Setup
Add a database user: choose a username and a strong password
Add your IP address to the allowlist (Atlas shows your current IP)
For local development only, you can use 0.0.0.0/0 to allow all IPs
Click "Finish and Close"
Connecting to Atlas
Atlas connection string format
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/myDatabase
Connect from Node.js
import { MongoClient } from 'mongodb'
const uri = "mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/myDatabase"
const client = new MongoClient(uri)
async function run() {
try {
await client.connect()
const db = client.db("myDatabase")
const users = db.collection("users")
const result = await users.findOne({ name: "Alice" })
console.log(result)
} finally {
await client.close()
}
}
run().catch(console.error)Atlas UI Overview
Collections browser — explore and edit documents in a GUI
Performance Advisor — automatic index recommendations based on query patterns
Real-Time Performance Panel — live ops/sec, connections, and query latency
Atlas Search — full-text search powered by Apache Lucene
Data Federation — query across Atlas, S3, and HTTP sources with MQL
Charts — build dashboards and visualizations directly from your data
Triggers — run serverless functions on database events or a schedule
App Services — hosting, authentication, and sync for mobile/web apps
Atlas SQL — query MongoDB with standard SQL via JDBC/ODBC drivers
Performance Advisor
Performance Advisor continuously monitors your slow queries (those taking longer than 100 ms by default) and suggests indexes that would speed them up. It ranks suggestions by their impact score — the estimated reduction in execution time across all affected queries. You can create the suggested index with a single click without touching the shell.
Atlas Search
Atlas Search is full-text search built on Apache Lucene, integrated directly into your Atlas cluster. You define search indexes in the Atlas UI or via the API, then query with the $search aggregation stage — no separate search infrastructure required.
Atlas Search query
// Find products whose name or description matches "wireless headphones"
db.products.aggregate([
{
$search: {
index: "default",
text: {
query: "wireless headphones",
path: ["name", "description"],
fuzzy: { maxEdits: 1 },
},
},
},
{ $limit: 10 },
{ $project: { name: 1, price: 1, score: { $meta: "searchScore" } } },
])Atlas Triggers
Atlas Triggers let you run serverless JavaScript functions automatically in response to events — no always-on server required: - Database Triggers — fire on insert, update, replace, or delete events in a collection. Use them to send notifications, sync data to another service, or enforce business rules. - Scheduled Triggers — run on a cron schedule. Useful for nightly aggregations, sending digest emails, or cleaning up expired records. - Authentication Triggers — fire when a user registers, logs in, or is deleted from App Services. Use them to set up new user profiles.
Pricing Tiers
Tier | RAM | Storage | Use Case |
|---|---|---|---|
M0 Free | Shared | 512 MB | Learning and prototyping |
M10 | 2 GB | 10 GB | Development and staging |
M30 | 8 GB | 40 GB | Production workloads |
M50+ | 16 GB+ | Custom | High traffic and large datasets |