uber / tchannel

network multiplexing and framing protocol for RPC
MIT License
1.15k stars 129 forks source link

Add simulation of accumulated connections during service startup #1397

Open kriskowal opened 8 years ago

kriskowal commented 8 years ago

When a large service starts all workers rapidly, the first workers to advertise will receive connections from all of their relays. This simulation answers the question: "How many workers have to advertise before each additional worker receives a reasonable number of connections."

Assuming that all workers start in order, more quickly than non-affine connections can be closed, the number of connections each subsequent worker receives drops linearly.

However, if workers start in random order, the number of connections each subsequent worker receives drops off multiplicatively.

As a consequence, we should avoid starting services in order or sort them by consistent hash instead of address. We should also consider introducing connections to newly discovered affine peers gradually (to avoid slamming p workers with k connections during startup). It may be desirable to reap non-affine connections frequently enough to collect some of them over the course of a rolling deployment. A rolling start/restart should take a few minutes, so non-affine connection reaping should probably happen once or twice per minute at least. We are thinking to avoid reaping peers too frequently to prevent flapping connections for slight adjustments to the Hyperbahn ring.

chart