DEV Community

mahiuddinTuhin
mahiuddinTuhin

Posted on

Understanding The Sharding in MongoDB

Before understanding sharding, we need to understand the vertical and horizontal scaling of the Database.

Suppose your data collection has a big growth and now you must extend your database server. If you extend the capacity of your database server eg. RAM, ROM or CPU then it would be called verticle scaling of the database.

Image description

But if you increase the number of servers to divide the data into chunks and distribute data into those multiple small servers, that would be called horizontal scaling of the database.

Image description

Now, let's come to the Sharding in MongoDB. Sharding in MongoDB is a method or approach for distributing or partitioning data across multiple machines, that is the horizontal scaling of the MongoDB database. It is beneficial when a single machine can't handle properly large modern-day workloads or data(eg. ~100 million of data) anymore. Then enabling horizontal scaling of the database by distributing chunks of data. This means you are adding several server machines into your server rack so that all the data can be shared with the data set and loaded within all the servers of the rack. Horizontal scaling allows us for near-limitless scaling to handle big data and intense and massive workloads.

Image description

Top comments (0)