MongoDB 3.0 was recently released. Instead of focusing on
what’s new – that is so easy to find, let’s rather talk about
something that has not changed a lot since the early MongoDB
days. This topic is sharding and most specifically: how to choose
a good sharding key. Note that most of the discussion will also
apply to MySQL, so if you are more interested in sharding than in
MongoDB, it could still be worth reading.
When do you want to shard?
In general sharding is recommended with MongoDB as soon as any of
these conditions is met:
- #1: A single server can no longer handle the write workload.
- #2: The working set no longer fits in memory.
- #3: The dataset is too large to easily fit in a single
server.
Note that #1 and #2 are by far the most common reason why people
need sharding. Also note that in the MySQL world, #2 does not
imply that you need sharding.
…
[Read more]