Mongodb Sharding: Concepts, Examples & Tutorials
This Comprehensive Article Explores Sharding in Mongodb. We Break the Article into Two Sections: Concepts, Components, Pros & Cons a Step-by-Step Tutorial on...
This comprehensive article explores sharding in MongoDB. We break the article into two sections:
- Concepts, components, pros & cons
- A step-by-step tutorial on setting up sharding
(This article is part of our MongoDB Guide. Use the right-hand menu to navigate.)
What is sharding?
Sharding is the process of distributing data across multiple hosts. In MongoDB, sharding is achieved by splitting large data sets into small data sets across multiple MongoDB instances.
Must Read
How sharding works
When dealing with high throughput applications or very large databases, the underlying hardware becomes the main limitation. High query rates can stress the CPU, RAM, and I/O capacity of disk drives resulting in a poor end-user experience.
To mitigate this problem, there are two types of scaling methods.
Vertical scaling
Vertical scaling is the traditional way of increasing the hardware capabilities of a single server. The process involves upgrading the CPU, RAM, and storage capacity. However, upgrading a single server is often challenged by technological limitations and cost constraints.
Horizontal scaling
This method divides the dataset into multiple servers and distributes the database load among each server instance. Distributing the load reduces the strain on the required hardware resources and provides redundancy in case of a failure.
However, horizontal scaling increases the complexity of underlying architecture. MongoDB supports horizontal scaling through sharding—one of its major benefits, as we’ll see below.