Sharding (overview) in MongoDB

advance ยท MongoDB โ€” Documents & data modeling

๐Ÿ”น What is Sharding? Sharding is a method of splitting large data across multiple machines (servers) . Instead of storing all data in one server MongoDB distributes data into smaller parts called shards Simple: Big data โ†’ split โ†’ store on multiple servers ๐Ÿ”น Why Sharding is Used Handles very large data Improves performance Supports horizontal scaling ๐Ÿ”น How it Works Data is divided based on a shard key Each shard stores a portion of data MongoDB automatically routes queries ๐Ÿ”น Example Users collection with millions of records: Shard 1 โ†’ users Aโ€“M Shard 2 โ†’ users Nโ€“Z Data is distributed ๐Ÿ”น When to Use Sharding Use sharding when: Data size is very large Single server cannot handle load Queries are becoming slow High read/write traffic Need to scale horizontally ๐Ÿ”น When NOT to Use Small datasets Low traffic applications Can be handled with indexing or replication ๐Ÿ”น Key Term Shard Key โ†’ field used to divide data Choosing good shard key is very important Simple Understanding Sharding = distribute data Helps with scaling and performance

Back to MongoDB โ€” Documents & data modeling

Browse all study material on Careeroza