In the world of MongoDB, it is very simple to do data distributed storage. As long as the cluster is completed as described above, it is fully equipped with the requirements of data distributed storage.
Here are a few concepts to distinguish: Go to the previous article can find the introduction
1. The replica set function is to achieve data backup, disaster recovery, the primary node and the same data from the node.
2. Shards Each shard consists of one or more replica sets, and the function is the data implementation distribution. All shards of data add up to form the complete data of a database.
3. The cluster is comprised of one or more shards + Mongos + configserver.
This is, of course, a condition for distributed storage of data. But the real realization of the data distribution is a key factor-"tablet key". The data distribution can be stored only by selecting the appropriate chip key.
Otherwise the data is still written on one shard.
For example, select the slice key to _id value to hashed. The basic realization of the data evenly distributed.
If you select a time value of 1 (ascending order). Data fragmentation is basically stored in time periods.
How to achieve the data distribution needs to be judged according to the business situation. A good chip key will improve the performance of query writing. Choosing a bad word can seriously affect system performance. I hope you can choose carefully.
For the selection of the chip key can refer to the next article "How to select the Tablet key"
MongoDB Data Distributed Storage