What is sharding and how it can be used with MongoDB?

What is sharding and how it can be used with MongoDB?

Posted in : MogoDB Posted on : July 5, 2014 at 1:29 PM Comments : [ 0 ]

In this section you will learn about the sharing with MongoDB.

MongoDB Sharding - How Sharding works with MongoDB?

Storing valuable data across multiple machines is called sharding and particularly it plays an important role in MongoDB database because of its rigorous approach to meet the demands of increasing data volume. Sharding or storing data across multiple machines become crucial when the data volume goes really big. A single machine may not be enough or effective always for a large volume of data to work on and hence sharding is crucial in data process. Through sharding you can easily add more number of machines to meet the demands of growing data and their uses. Here below we discuss briefly about the effectiveness of sharding and how it works in MongoDB.

Why Sharding is necessary?

Sharding is crucial in the data process for multiple reasons. Here we are mentioning a few in brief.

  • While in replication all writes invariably go to master nodes, sharding saves you from this trouble.
  • In sharding there is hardly any limitation in respect of maintaining data copies, while in replication the replica set has the limit of 12 nodes on the maximum side.
  • When working data set is big enough to handle by your memory, sharding is the best help.
  • Through sharding you avoid having big local disks and also save the high cost of vertical scaling.

How sharding works in MongoDB?

Through the 3 main components sharding works in MongoDB which we will introduce below in brief.

  • Through shards or separate replica set to maintain data consistency
  • Through configuration servers that stores meta data of the server and mapping of the shards.
  • Through query routers that interacting with the client direct queries or applications to appropriate shards.

Approaches of Sharding

  • Vertical scaling and
  • Sharding

Vertical scaling

The Vertical scaling is done by adding more CPUs and storage resources. But this is more expensive and there is a limitation of the hardware.


In horizontal scaling or simply Sharding the data sets are distributed over multiple servers which is know as shards. Each shard is independent database and collectively many shards makes a single logic database. Such type of Sharding is capable of recovering the server fail our and provides high throughput.

Next tutorial: MongoDB Replication

Go to Topic «PreviousHomeNext»

Your Comment:

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image

Tutorial Topics