21 Operational excellence with MongoDB Atlas
MongoDB Atlas centralizes operational excellence with managed resilience, security, and efficiency features. The chapter explains Atlas Cloud Backups across tiers, from manual dumps for free clusters to automated snapshots on Flex and full-featured schedules, on‑demand snapshots, retention policies, and customer‑managed encryption on dedicated clusters. It details restorations—from snapshot and point‑in‑time recovery using continuous backups (oplog capture) to restoring in place or to an alternate cluster—highlighting that Atlas wipes target data to ensure consistency, briefly takes clusters offline during restore, and urges regular restore testing for reliability and compliance.
For performance and cost control, Atlas provides end‑to‑end observability and optimization: Performance Advisor suggests indexes and flags inefficient query patterns; the Query Profiler, Real‑Time Performance Panel, and Namespace Insights surface live and historical hotspots, latency, and resource bottlenecks (many tools available on M10+). Schema suggestions guide data model refinements to match access patterns. Native diagnostic commands—serverStatus, currentOp/killOp, top, dbStats/collStats, and replication info—offer granular, node‑level insight into load, queuing, locking, and lag, enabling targeted tuning, right‑sizing, and capacity planning.
Robust alerting and logging round out operational safeguards. Teams define alert conditions and thresholds (for example, CPU steal, queues, query targeting, and connection saturation) and route notifications through preferred channels for rapid response. Atlas surfaces database, audit, and trigger logs (with tier‑based retention and download constraints) and supports secure forwarding to external observability platforms or long‑term storage. Finally, the chapter underscores disciplined upgrades: automatic, rolling minor updates within maintenance windows; planned major version upgrades performed one step at a time on healthy clusters with driver compatibility checks. Together, these practices sustain reliability, performance, security, and predictable growth on Atlas.
The primary node (P) and secondary nodes (S) are all located within the same region (Region 1). Backups are created by taking snapshots of these nodes, prioritizing secondary nodes where possible to reduce impact on the primary node. If a new snapshot storage volume is required, it is created within the same region. This setup ensures that all backups remain in the same geographic area as the original data, following Atlas's single-region backup policy.
Summary
- Database backups are crucial for data integrity and resilience. They allow quick recovery if data is accidentally deleted or in cases of corruption, maintaining business continuity. In cybersecurity, backups are key for recovery, especially during ransomware attacks, as secure backups can restore data without paying a ransom.
- MongoDB Atlas provides Cloud Backup, a managed service that automatically stores point-in-time snapshots of clusters using AWS, Azure, or Google Cloud. It supports scheduled and on-demand snapshots, offering options like continuous backups with point-in-time recovery to ensure data protection and policy compliance.
- Atlas cloud backups are unavailable for M0 Free clusters. Instead, you can use tools like mongodump to create backups and mongorestore for data restoration. mongodump generates a logical backup by extracting database content and saving it as BSON files, rather than copying the physical data layer.
- Atlas cloud backup for Flex clusters is limited to automatic daily snapshots, starting 24 hours post-setup. On-demand snapshots aren’t supported, but cloud provider snapshots enable quick restoration.
- Dedicated clusters (M10 and above) offer advanced cloud backup options, leveraging cloud providers' native snapshot capabilities to create full-copy snapshots stored in the same region. Snapshots can be scheduled regularly, with configurable retention policies, and on-demand snapshots are available for backups anytime.
- Continuous Cloud Backups offer robust data protection with point-in-time recovery, continuously capturing database changes for restoration at any moment within a set retention window. Available for M10 and higher clusters, this feature may increase costs due to additional storage and processing. The backup window duration can be configured to meet specific recovery needs.
- In Atlas, mongorestore doesn’t support --restoreDbUsersAndRoles, --oplogReplay, or --preserveUUID, so users and roles must be recreated manually, restored collections will receive new UUIDs, and there is no point-in-time restore option.
- When restoring from a Cloud Backup, the target cluster is prepared to match the exact state of the selected snapshot or backup point. To achieve this, Atlas first clears all existing data on the target cluster, avoiding any potential conflicts or inconsistencies. This clean start ensures that the cluster can be accurately restored to reflect the data as it was at the backup time.
- MongoDB Atlas offers real-time monitoring and alerting for database performance, health, and resource usage. You can track metrics like CPU, memory, disk I/O, and active connections to spot issues early. Custom alerts can be set for specific thresholds, with notifications sent automatically via email, SMS, or integrations like PagerDuty and Slack.
- The Performance Advisor monitors slow queries and suggests indexes to boost performance, adjusting thresholds based on your cluster’s average operation time. Each index recommendation includes sample queries that would benefit from it, grouped by query structure.
- MongoDB Atlas offers the Query Profiler, a tool for diagnosing and monitoring database cluster performance. The Query Profiler identifies slow queries and provides key metrics like execution time and server processing time, allowing for in-depth analysis across clusters or individual nodes.
- The Real-Time Performance Panel (RTPP) is a live monitoring tool that tracks key metrics like CPU, memory, disk, and network usage, helping identify bottlenecks and manage database performance proactively.
- Namespace Insights in MongoDB Atlas offers detailed collection-level metrics on query latency, helping teams monitor response times and pinpoint collections with high latency or inefficient queries for targeted optimizations.
- Atlas offers schema suggestions to optimize database performance by analyzing high-traffic collections and slow queries. It recommends changes like field restructuring, index optimization, and data type adjustments to reduce bottlenecks.
- Apart from Atlas's built-in monitoring tools, you can use native MongoDB diagnostic commands, which provide direct insights into server performance, resource usage, and potential bottlenecks. Many of Atlas's tools use these commands under the hood. Key commands include: serverStatus, dbStats, collStats, currentOp, top, and replSetGetStatus.
- Logging records system activities for troubleshooting and security, while alerting notifies admins of critical issues instantly. Together, they ensure performance, security, and reliability by tracking and responding to issues proactively.
- You can set alerts in Atlas for specific conditions, including CPU Steal, Queues, Query Targeting, and Connection Limits. Each condition monitors essential performance metrics to help maintain cluster health.
- Enable an alert with atlas alerts settings enable <alertConfigId>, delete it with atlas alerts settings delete <alertConfigId>. List all alerts using atlas alerts list, and view details with atlas alerts describe <alertId>.
- MongoDB Atlas provides logging for effective database monitoring, including database logs for instance activities (kept for 30 days), audit logs for tracking database actions, and trigger logs for application events (kept for 10 days). Logs are accessible via the Atlas UI or CLI.
- Regular MongoDB Atlas upgrades ensure security, performance, and new features. Minor upgrades, like from 8.0.3 to 8.0.5, are automatic during maintenance, focusing on patches and stability. Major upgrades, such as from 7.0 to 8.0, require manual initiation and introduce significant changes, needing a healthy cluster and completed snapshots.
MongoDB 8.0 in Action, Third Edition ebook for free