How does zero move the larger shard in the group to other groups?

When the amount of data in a group is large, will zero move the larger shard in the group to other groups? How did it move? Does the copy on the copy also move?

1 Like

Yes, Zero moves the shards from larger size groups to smaller size groups (see --rebalanceInterval flag). Periodically after that interval, it checks if rebalancing would be useful. The rebalancing decision is based on heuristics (currently it just uses size of groups, maybe query traffic could be another parameter to try on later).

The logic for that decision can be seen here in the code. To summarize:

  1. Sort the groups on the basis of size.
  2. Decide srcGroup: Find the active group (from largest → smallest), and see if the size difference with the smallest group is big enough that it would be advantageous to move.
  3. Decide tablet from srcGroup: Finds a tablet as big a possible such that on moving it dstGroup’s size is less than or equal to srcGroup.

You can see it here. Feel free for follow-ups.

Can you please elaborate on what you mean by this?

1 Like