Introducing Dragonfly Cloud! Learn More

Question: How scalable is MongoDB Atlas?

Answer

MongoDB Atlas is a fully managed cloud database service that provides scalability, flexibility, and security for your MongoDB databases. Scalability in MongoDB Atlas is achieved through a combination of features and options designed to help you efficiently manage database workloads of varying sizes and complexities.

Horizontal Scaling (Sharding)

MongoDB Atlas supports horizontal scaling via sharding. Sharding is the process of distributing data across multiple servers or instances, allowing the database to scale out on demand. This is particularly useful for applications with very large datasets or high throughput requirements.

In MongoDB Atlas, you can enable sharding automatically when setting up your cluster or modify an existing cluster to add sharding later. The platform provides options to choose your shard key wisely, balancing write and read operations across shards.

Vertical Scaling

Atlas also offers vertical scaling, which involves increasing the computational resources (e.g., CPU, RAM) of your existing servers. This can be done with just a few clicks in the MongoDB Atlas UI or via the API. Vertical scaling is a straightforward way to boost performance for workloads that have not yet reached the point where sharding is necessary.

Auto-Scaling

One of the key features of MongoDB Atlas is its ability to auto-scale your clusters vertically. You can set thresholds for CPU, memory, and disk I/O usage that, when reached, will trigger Atlas to automatically adjust your cluster's resources. This ensures that your application maintains optimal performance without manual intervention.

Global Clusters

For applications that serve a global user base, MongoDB Atlas offers Global Clusters. These are specially configured clusters that allow you to geographically distribute your data to reduce read and write latencies and provide a better user experience worldwide.

Load Balancing

MongoDB Atlas automatically balances connections and queries across the nodes in your cluster, ensuring even workloads and optimizing resource utilization. This load balancing capability is critical for maintaining high performance as your application scales.

Example: Scaling a Cluster

Although including specific code examples for scaling might vary greatly depending on your cluster setup and requirements, scaling a cluster manually or setting up auto-scaling can easily be done through the MongoDB Atlas web interface. To manually scale a cluster:

  1. Go to the Clusters page on the MongoDB Atlas dashboard.
  2. Click the ... menu next to your cluster, then select Edit Configuration.
  3. Here, you can adjust your instance size (vertical scaling), modify the number of nodes, or enable sharding (horizontal scaling).
  4. Review the changes and costs, then apply the changes.

For auto-scaling, navigate to your cluster's settings and enable 'Auto-scale cluster tier', configuring the desired thresholds.

Conclusion

MongoDB Atlas is built with scalability in mind, offering several mechanisms to ensure that your database can grow alongside your application. Whether through sharding, vertical scaling, auto-scaling, or leveraging global clusters, Atlas provides the tools necessary to handle both sudden spikes in demand and long-term growth.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.