-
Notifications
You must be signed in to change notification settings - Fork 112
Improve Request Sharding #167
Comments
@Stebalien do you know if this is true? It seems like it should be but I'm not sure |
IMO, this is the primary issue. This limit should be per-peer. We may also want some kind of global wantlist rate limit but thats a different issue. When a we run out of want limit slots for a peer, that peer should be put on hold till a slot opens up.
In general, it is. |
@Stebalien the live want queue should increase, but I think @dirkmc is right that the current approach tends to mean we aren't actually sharding because we only get one new want at a time. And that would be true even if the live wants increased. I like the streaming idea. I do also like the idea of removing the session live want list and tracking on a per peer baseis. |
The following proposal takes a step in the direction of a more sophisticated model, but assumes that for now there are no protocol extensions (in #166 we discuss extending the protocol). The goals are:
SessionDiscoveryFollow the current model:
Want PotentialThe session orders wants by potential (greatest - lowest), then by FIFO.
Per-peer rate limiting (for session)Note: This section discusses rate-limiting peers on a per-session basis. Below we discuss rate-limiting requests from all sessions to a peer. We want to trade-off
The session increases the rate-limit for a peer exponentially as it receives blocks. When a peer is discovered:
Want StreamFor each want, the session selects a peer probabilistically such that the probability
Peer BrokerPeers have a limited-size want request queue (the limit applies to all requests from all sessions). The Peer Broker manages the want queue for each peer. The Peer Broker performs matching when both these conditions are true:
The Peer Broker repeatedly asks the sessions in round robin fashion if they are interested in the currently available peers. The peer is allowed to send a message each time
Note that this implies that sessions must decide quickly if they are interested in sending a want to one of the candidate peers, so as not to block peers that are waiting to send out a message. |
"Expected wants"?
We'd also like to avoid forcing the peer to maintain a massive wantlist for us. Although I guess that might be the job of the peer broker.
What's the rational behind this?
Note: For the purposes of throughput, separate sessions might as well be Instead, we should optimize for downloading the content as fast as we can. If we do that, we'll automatically pick the peers with the most available bandwidth. (Ok, that kind of assumes that these peers are getting their bandwidth maxed out. Doing some local load balancing across peers is still useful, we just shouldn't focus on it too hard).
This should be 1.
?
You mean starts higher?
I think this section mixes peer/session a few times.
That sounds really wasteful. |
There are a lot of knobs here that could behave in ways we're not expecting. When possible, let's try to map them directly onto desired effects. Ideally, each one would follow the following rule:
"Want Potential" does this really well: increase duplicate requests until we start getting duplicate responses, then decrease. Let's reason through how all the other knobs correlate to throughput (or fairness). |
If we don't rate-limit per session, then the session may request all its blocks from the first peer that responds. For example in a scenario where the per-peer rate-limit is 128, and there haven't been any requests yet:
Perhaps in this scenario overall throughput would have been higher if the local node requested 10 blocks from
I proposed an exponentially increasing session rate-limit per-peer as a way to try to spread the requests across peers in the discovery stage of a session's requests, then quickly move to optimizing for the fastest responding peers as we move out of discovery. I'm open to other ways of doing this.
Here I'm suggesting that
Yes. My thinking is that if nearby peers are downloading the same file from the seed, we should send wants to them so as to maximize throughput.
The idea is that we want to process blocks as a stream (one-by-one). The Peer Broker knows how much space each peer has, and repeatedly asks each Session if it would like to send to any of the peers with free space. As the want lists for the peers fill up, the list of candidate peers will change. The peer can send its message only once no more sessions want blocks, or once a peer's want list is full (so that we're not sending lots of messages with a single want).
Sounds like a good approach 👍 |
#165 outlines session request sharding in Bitswap. Each session maintains a list of peers that have responded to a wantlist request with a block, ordered by latency. Requests are split such that groups of CIDs (wants) are sent to groups of peers. As responses come in, the session adjusts the split factor up or down to maintain a balance between redundancy and too many duplicates.
Responses are processed on a block-by-block basis
The live want queue has 32 slots. Once the queue is full, then each time a response block is processed
However the splitter is designed to work over groups of blocks, not a single block. So regardless of the split factor, blocks will always be sent to the same peers until the split factor changes.
For example if there are 8 peers (A - H) and the split factor is 3, the peers will be split into three groups. The CID will be sent to the peers in the first group and the other two groups will be disregarded:
All blocks will be sent to peers
A
,D
andG
until the split factor changes. Regardless of the split factor, blocks will always be sent to peerA
.Shard wants on a streaming basis
It would be better for a few reasons if all blocks in the response were processed as a group, however quite often the response contains a small number of blocks anyway, so any solution should be able to handle a single block as well as several blocks.
There is a WIP PR to adjust the peer list order probabilistically, which should mitigate the problem, as the order of peers will change somewhat with each request. However it may be easier to reason about the problem if wants are instead sharded on a streaming basis.
Sharding should
N
peers to send the block to.N
is analogous to the split factor: it should vary to find a balance between redundancy and too many duplicates.Asking nearby peers we are already connected to for a block is a relatively cheap operation. If several peers are downloading the same data, we want them to quickly start downloading from each other so as to
The text was updated successfully, but these errors were encountered: