Answer the question
In order to leave comments, you need to log in
Sharding. How to distribute users?
Hello.
I read various materials on sharding and almost everywhere they talk about calculating hashes, remainders from division, etc., but it’s not entirely clear to me why such complexity (relative), so please help me figure it out.
That is, for example, we are designing a social network that will be super-megafacebook2 with a billion users.
We create 1000 virtual shards on one physical server. 1 billion / 1000 = 1,000,000 users per virtual shard.
Actually, the question is: why calculate the hashes of logins, etc. to scatter users across different shards, if you can simply register users on the first virtual shard until their number on it reaches the planned one (in our example, 1 million)? That is, a user is registered, we check if our virtual shard does not yet have a million users, then we register it for the first one, if there are already a million users, then we register the user for the second one, and so on. If there is a lot of data, then we transfer part of the virtual shards to another physical server.
Where am I wrong in my reasoning? what are these hashes for if you can start from the amount of data? Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question