[Draft] Rework routing to be node based rather than shard based #6117
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today, a specific shard on a specific node is targeted for persisting a request. This is suboptimal; we can pick a node that we know has at least one shard on it and delegate the shard selection logic to it.
In order to do that, the routing table needs to be aware of per-node level shards, not just local/remote shards. This reworks the routing table to maintain a single map of <Node, Vec>. A preference is given to the node with the most open shards. TODO: make it psuedorandom, but weigh nodes with more open shards higher.
As a result, some other shapes changes. I tried to be minimally intrusive when making the changes, but there's a lot that can go wrong here (shard updates, etc)
I'm not sure yet as to what the effects will be on retries and things of that nature. So that's also something to keep in mind.