Database Reference
In-Depth Information
Now if we run sh.status() again, you can see the ranges; this time, things look to be running better:
testdb.testtagsharding
shard key: { "region" : 1, "testkey" : 1 }
chunks:
shard0001 3
shard0000 1
{ "region" : { "$minKey" : 1 }, "testkey" : { "$minKey" : 1 } } -->> { "region" :
"EU", "testkey" : { "$minKey" : 1 } } on : shard0001 Timestamp(4, 0)
{ "region" : "EU", "testkey" : { "$minKey" : 1 } } -->> { "region" : "EU", "testkey"
: 0 } on : shard0001 Timestamp(2, 0)
{ "region" : "EU", "testkey" : 0 } -->> { "region" : "US", "testkey" : { "$minKey" :
1 } } on : shard0001 Timestamp(3, 0)
{ "region" : "US", "testkey" : { "$minKey" : 1 } } -->> { "region" : { "$maxKey" : 1 },
"testkey" : { "$maxKey" : 1 } } on : shard0000 Timestamp(4, 1)
tag: EU { "region" : { "$minKey" : 1 } } -->> { "region" : "US" }
tag: US { "region" : "US" } -->> { "region" : { "$maxKey" : 1 } }
Our data is better distributed, and the ranges involved cover the whole range of shard keys from the minimum
value to the maximum value. If we further insert entries into the collection, their data will be correctly routed to our
desired shards. No mess and no fuss.
Summary
Sharding enables you to scale your datastores to handle extremely large datasets. It also enables you to grow the
cluster to match the growth in your system. MongoDB provides a simple automatic sharding configuration that
works well for most requirements. Even though this process is automated, you can still fine-tune its characteristics to
support your specific needs. Sharding is one of the key features of MongoDB that set it apart from other data-storage
technologies. Following this chapter you should understand how to shard your data over a number of MongoDB
instances, manage and maintain a sharded cluster, and how to take advantage of tag sharding and hashed shard keys.
We hope this topic has helped you see the many ways that MongoDB is designed to cope better with the rigorous
demands of modern web-based applications than is possible using more traditional database tools.
Topics you have learned about in this topic include the following:
How to install and configure MongoDB on a variety of platforms.
How to access MongoDB from various development languages.
How to connect with the community surrounding the product, including how to obtain help
and advice.
How to design and build applications that take advantage of MongoDB's unique strengths.
How to optimize, administer, and troubleshoot MongoDB-based datastores.
How to create scalable fault-tolerant installations that span multiple servers.
You are strongly encouraged to explore the many samples and examples provided in this topic. Other PHP
examples can be found in the PHP MongoDB driver documentation located at www.php.net/manual/en/book.
mongo.php . MongoDB is an extremely approachable tool, and its ease of installation and operation encourage
experimentation. So don't hold back: crank it up and start playing with it! And remarkably soon you, too, will begin to
appreciate all the possibilities that this intriguing product opens up for your applications.
 
Search WWH ::




Custom Search