Skip to content

Commit 1c2901d

Browse files
committed
add description of FDQueue and backpressure
1 parent a43e827 commit 1c2901d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

docs/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,17 @@ State descriptions:
208208
209209
More details in [../replication](../replication).
210210
211+
One important thing for replication that is kind of outside of protocol is FDQueue.
212+
When replication protocol broadcasts some packets it calls Broadcast method on host.
213+
Chotki structure has outqueue field which is a map of FDQueues. Broadcast will iterate over all entries
214+
of this map and will call Drain. FDqueue is a thing that Syncer will check when Feed would be called on it byt network. So, the contents of the queue will be forwarded to the other replica. FDQueue implements few optjmisations:
215+
216+
- feed will wait until some reasonable amount of packets accumulate (or some time pass)
217+
- it has some MAX bytes data it can handle after which it overflows and basically stops working
218+
In case of overflow during Broadcast call the error will be returned and this FDQueue will be deleteted from outqueue map. It doesnt stop the syncing, but other replica will stop receiving any data from this one and next ping event will drop the connection, because there will be no way to respond.
219+
220+
It shouldn't happen normally, only when network can't fan out all of the data to other replica due to network problems or other replica can't handle the amount of data it receives. So this is kind of backpressure.
221+
211222
# Networking
212223
213224
Chotki implements a high-performance, callback-driven networking layer optimized for continuous bidirectional streaming between replicas.

0 commit comments

Comments
 (0)