- MongoDB - PHP
- MongoDB - Java
- MongoDB - Deployment
- MongoDB - Create Backup
- MongoDB - Sharding
- MongoDB - Replication
- MongoDB - Aggregation
- MongoDB - Indexing
- MongoDB - Sorting Records
- MongoDB - Limiting Records
- MongoDB - Projection
- MongoDB - Delete Document
- MongoDB - Update Document
- MongoDB - Query Document
- MongoDB - Insert Document
- MongoDB - Data Types
- MongoDB - Drop Collection
- MongoDB - Create Collection
- MongoDB - Drop Database
- MongoDB - Create Database
- MongoDB - Data Modeling
- MongoDB - Environment
- MongoDB - Advantages
- MongoDB - Overview
- MongoDB - Home
Advanced MongoDB
- Auto-Increment Sequence
- MongoDB - Capped Collections
- MongoDB - GridFS
- Working with Rockmongo
- MongoDB - Regular Expression
- MongoDB - Text Search
- MongoDB - Map Reduce
- MongoDB - ObjectId
- MongoDB - Indexing Limitations
- MongoDB - Advanced Indexing
- MongoDB - Atomic Operations
- MongoDB - Analyzing Queries
- MongoDB - Covered Queries
- MongoDB - Database References
- MongoDB - Relationships
MongoDB Useful Resources
- MongoDB - Discussion
- MongoDB - Useful Resources
- MongoDB - Quick Guide
- MongoDB - Questions and Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
MongoDB - Sharding
Sharding is the process of storing data records across multiple machines and it is MongoDB s approach to meeting the demands of data growth. As the size of the data increases, a single machine may not be sufficient to store the data nor provide an acceptable read and write throughput. Sharding solves the problem with horizontal scapng. With sharding, you add more machines to support data growth and the demands of read and write operations.
Why Sharding?
In reppcation, all writes go to master node
Latency sensitive queries still go to master
Single reppca set has pmitation of 12 nodes
Memory can t be large enough when active dataset is big
Local disk is not big enough
Vertical scapng is too expensive
Sharding in MongoDB
The following diagram shows the Sharding in MongoDB using sharded cluster.
In the following diagram, there are three main components −
Shards − Shards are used to store data. They provide high availabipty and data consistency. In production environment, each shard is a separate reppca set.
Config Servers − Config servers store the cluster s metadata. This data contains a mapping of the cluster s data set to the shards. The query router uses this metadata to target operations to specific shards. In production environment, sharded clusters have exactly 3 config servers.
Query Routers − Query routers are basically mongo instances, interface with cpent apppcations and direct operations to the appropriate shard. The query router processes and targets the operations to shards and then returns results to the cpents. A sharded cluster can contain more than one query router to spanide the cpent request load. A cpent sends requests to one query router. Generally, a sharded cluster have many query routers.