How to split data into each shard of user_id in Mongo?

I have 3 shards

Instead of autoload, I can determine that specifically shard1 contains only data that is with user_id = 1 and shard2 with user_id = 2 and shard3 with user_id = 3?

+4
source share
1 answer

You can follow the manual splitting and delineating route and turn off the balancer, but a more scalable solution might be to try out the new shrapnel marking in 2.2

The Kristina example is intended to show how to manage the distribution of a collection, but you can adapt it for your own purposes, say tag fragments for specific ranges of users in both collections to ensure their location on a specific fragment.

You still have to manage this yourself, but at least it takes the burden off you in terms of block management and migration.

+2
source

Source: https://habr.com/ru/post/1432681/


All Articles