Scalability is a major concern for all modern businesses, which is why it’s our second reason to migrate to MongoDB. Your applications and systems must adapt to unexpected demands along with the normal growth rate of your organization. Due to MongoDB being a NoSQL database, it supports horizontal scalability through a process called sharding.
Sharding separates larger databases into smaller partitions to improve performance. MongoDB comes with three sharding methods built-in:
Your data gets separated into contiguous ranges based on the shard key value. For example, if two documents have shard key values that are close to one another, they end up getting located in the same shard. You typically use ranged sharding for applications that perform many range queries. Due to this configuration, you don’t have equal distribution of the data stored on your servers.
The data gets distributed uniformly across the shards. The location is determined by the hash of the shard key value, which means that two documents with close shard key values generally don’t end up in the same shard. You’re covering a range of data, rather than pulling an exact value.
Hashed sharding makes the most sense for applications that write frequently to the database. You can increase the shards to get better performance out of read/write operations, as these operations are evenly distributed throughout this grouping.
You choose a specified trait that controls the data distribution. Some common parameters include the geographic location of the data, hardware configuration, or other shard values or ranges. You can associate a zone with more than one shard as well.
This method works well if you need your data sharded in a particular way to support the operations of your application. A common use case is improving data locality when you have your databases spread throughout multiple data centers.
MongoDB allows you to cluster shards together to increase the availability of the data and to continually grow your storage space for your databases.
Why Use MongoDB Atlas for Sharding
MongoDB has these sharding methods built-in, so you might wonder what Atlas can bring to the table to make it even better. MongoDB Atlas includes support for automatic sharding when you’re scaling, which eliminates the need for downtime during this process.
The data automatically gets balanced across the shards as your database grows larger. This configuration bypasses the limitations of a single server. The service also promises zero downtime when you’re scaling your databases up to larger instances.
Implementing MongoDB Atlas
Automated sharding is an attractive feature, especially when your company requires a lot of horizontal scalability for its databases. Migrating your databases to Atlas may seem like a daunting task, or one that you lack the in-house resources to perform.
Consider working with a managed service provider like Datavail that specializes in MongoDB and Atlas. We guide you throughout the entire migration process, from determining whether migration is a viable option for your infrastructure to optimizing your systems for performance. Having specialists with hands-on experience with this process is essential, as you can’t unshard a collection once you shard it.
Subscribe to Our Blog
Never miss a post! Stay up to date with the latest database, application and analytics tips and news. Delivered in a handy bi-weekly update straight to your inbox. You can unsubscribe at any time.
Most people will encounter this error when their application tries to connect to an Oracle database service, but it can also be raised by one database instance trying to connect to another database service via a database link.