Jump to content

User:Tim Starling (WMF)/LoadBalancer connection metric

From mediawiki.org

Take the adjusted connection count Ci which is the number of open connections plus the number of connection failures over the last 10 seconds.

Load weights which satisfy i=1nwi=1

The discrepancy between the desired connection count and the actual connection count is

ΔCi=CiwiT

where T=j=1nCj

A positive number indicates that the server has too many connections. We could normalize by the total connection count:

wi=wiqΔCiT

But that would be noisy when the number of connections is small. We could simply scale it:

wi=wirΔCi

That's defensible and easy to understand. Maybe it would get noisy with high traffic. We could combine the two:

wi=wiqΔCiE+T

or if you like, equivalently

wi=wisΔCi1+TE

where q, r, s and E are tunable constants.

Obviously you then have to clamp it so that wi0, and then scale it so that the weights add up to 1 again.

With S=1s the two tunable constants S and E can be thought of as connection counts. S is the connection count discrepancy which causes the load to be increased or decreased by 100% under low-traffic conditions. E is the total connection count at which the adjustment will be scaled down by half.