Sharding in layman
Darshan Jayarama
Sr. TSE @MongoDB | MongoDB Dual Certified Professional - C100DBA, C100DEV | Leader @ mdb.link/bengaluru-mug
A common question I get asked is, "What is Sharding?". Being the complex concept in MongoDB, One of my favorite ways to explain Sharding in plain language is to use an analogy of a wardrobe.
Our clothes are divided and organised in a wardrobe based on how we can access them. A drawer may contain separate compartments for shirts, t-shirts, trousers, and suits, for example. Alternatively, we may keep the matching garments in individual compartments, just like the matching Pants, Shirts, Ties & Belts. It may be preferable for some to keep the same cloth in the same compartment as well.?
The criteria for division are determined by how we gain access to it. In sharding, this is known as a "Shard Key."
If the clothes are arranged by type (shirt, t-shirt, trousers), the person arranging them will know which cloth is in each compartment. In compartment 1, there may be t-shirts, in compartment 2, there may be shirts, in compartment 3, there may be trousers, and so on. These are called "Shards". An individual who knows which type of cloth can be found in a specific compartment is known as a "config server".
If we need a t-shirt, we go straight to the corresponding compartment and get it. That's what we call a "targeted query". Suppose that the distribution is based on the type of cloth, and you would like to search for all red coloured cloth, you would have to search in every compartment; this is an example of a "distributed query".
You can learn more about sharding in M103 course. Feel free to post your questions in our community forum.
MongoDB SME - Database Architect | 4x-MongoDB Certified, 5x- Azure Cloud Certified - Azure Solutions Architect
2 年You made it easy !! Well explained ?????? Darshan Jayarama
love it!
Senior Software Engineer at Amazon | Ex Microsoft | Ex Amazon
2 年Your analogy looks a great example. You should add the definition of partioning and sharding so that people don't get confused between the two.I don't know how you would explain the difference between a sharding and partitioning with this analogy.
Associate @ Deutsche Bank | SQL, Python, Databases | SWIFT Financial Messaging | ISO20022
2 年Good way of explaining core concepts Darshan Jayarama
Technology Leader @ Citi
2 年Darshan Jayarama very well explained