I’m looking for a good approach to do the following :
Given a document with some field F I want to set up sharding to that my application can generate a static hash for that field value (meaning, the hash will always be the same if the value is the same) and then use that hash to target the appropriate shard in a normal MongoDB sharded setup.
Questions :
- Is this a safe/good approach?
- What is a good way to go about implementing it
- Are there any gotchas concerning shard cluster setup that I should be aware of.
Thanks!
I’ve actually implemented this and it’s very doable and results in very good write performance. I’m assuming you have the same reasons for implementing it as I did (instant shard targeting without warmup/balancing, write throughput, no performance degradation during chunk moves/splits, etc.).
Your questions :
Some downsides to consider :
Good luck.
UPDATE 25/03/2013 : As of version 2.4 MongoDB supports hash indexes natively.