Skip to content

Commit af59fbd

Browse files
committed
Sharding in MongoDB
1 parent 9df596b commit af59fbd

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Documents can be stored and retrieved in a form that is much closer to the data
2828
**Example:** Amazon SimpleDB, CouchDB, MongoDB, Riak, Lotus Notes are popular Document originated DBMS systems.
2929

3030
<p align="center">
31-
<img src="assets/document-database.png" alt="Document Databases" width="300px" />
31+
<img src="assets/document-database.png" alt="Document Databases" width="400px" />
3232
</p>
3333

3434
**2. Key-value Stores**
@@ -1103,8 +1103,34 @@ When running a 32-bit system build of MongoDB, the total storage size for the se
11031103
<b><a href="#">↥ back to top</a></b>
11041104
</div>
11051105
1106-
#### Q. ***Why are MongoDB data files large in size?***
1107-
#### Q. ***What is Sharding in MongoDB?***
1106+
## Q. ***What is Sharding in MongoDB?***
1107+
1108+
**Sharding** is a method for distributing data across multiple machines. MongoDB uses sharding to support deployments with very large data sets and high throughput operations.
1109+
1110+
Database systems with large data sets or high throughput applications can challenge the capacity of a single server. There are two methods for addressing system growth: vertical and horizontal scaling.
1111+
1112+
**1. Vertical Scaling**
1113+
1114+
Vertical Scaling involves increasing the capacity of a single server, such as using a more powerful CPU, adding more RAM, or increasing the amount of storage space.
1115+
1116+
**2. Horizontal Scaling**
1117+
1118+
Horizontal Scaling involves dividing the system dataset and load over multiple servers, adding additional servers to increase capacity as required. While the overall speed or capacity of a single machine may not be high, each machine handles a subset of the overall workload, potentially providing better efficiency than a single high-speed high-capacity server.
1119+
1120+
<p align="center">
1121+
<img src="assets/sharding.png" alt="Document Databases" width="400px" />
1122+
</p>
1123+
1124+
MongoDB supports horizontal scaling through `sharding`. A MongoDB sharded cluster consists of the following components:
1125+
1126+
* **Shards**: Each shard contains a subset of the sharded data. Each shard can be deployed as a replica set.
1127+
* **Mongos**: The mongos acts as a query router, providing an interface between client applications and the sharded cluster. Starting in MongoDB 4.4, mongos can support hedged reads to minimize latencies.
1128+
* **Config Servers**: Config servers store metadata and configuration settings for the cluster.
1129+
1130+
<div align="right">
1131+
<b><a href="#">↥ back to top</a></b>
1132+
</div>
1133+
11081134
#### Q. ***What is Aggregation in MongoDB?***
11091135
#### Q. ***How can you isolate your cursors from intervening with the write operations?***
11101136
#### Q. ***At what interval does MongoDB write updates to the disk?***

assets/sharding.png

40.8 KB
Loading

0 commit comments

Comments
 (0)