[zeromq-dev] patch: handle idle connections
Martin Sustrik
sustrik at fastmq.com
Mon Mar 30 09:31:05 CEST 2009
Dhammika Pathirana wrote:
>> What about removing connection x like this:
>>
>> if (x < active) {
>> std::swap (pipes [x], pipes [A-1]);
>> x = A = A - 1;
>> }
>> std::swap (pipes [x], pipes [pipes.size () - 1]);
>> pipes.resize (pipes.size () - 1);
>>
> This'll work, but can we guarantee fairness?
Strictly speaking no. We can't. When a connection is closed, some other
connection is taken and placed to the head of the processing queue
(current) thus gaining an unfair advantage.
However, in the long run there are two effects to take into consideration:
1. If disconnection is rare, its impact on the fairness dissipates with
the time. Say, if disconnection happens once a day and it causes
unfairness of 10us, the impact on the fairness of the system as a whole
is almost unmeasurable.
2. If disconnection is a frequent event, if gives unfair advantage to
lots of connections (the process of choosing of the connection given the
advantage is uniformly random) and the amount of unfairness assigned to
the connection is uniformly random as well. Consequently, in the long
run all the connections get almost exactly same amount of unfair
advantage thus making the system as a whole fair.
Combining the two effects above leads to the fact that amount of the
unfairness in the system doesn't run out of bounds at any disconnection
rate and that the upper bound converges to zero as the time window we
are using to observe the unfairness increases towards infinity.
Martin
More information about the zeromq-dev
mailing list