Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfreeze operators as soon as possible due to peers' expirations #581

Merged
merged 4 commits into from
Nov 30, 2020

Conversation

nolar
Copy link
Owner

@nolar nolar commented Nov 17, 2020

Unfreeze operators when the blocking peers (other operators of the same "peering neighbourhood") are supposed to expire, not when the next keepalive happens as it was before.

This will reduce the waiting time for up to 60 seconds to much lower delay. However, delays of 60 seconds are still possible but less probable: if the blocking operators have sent their keepalives moments before exiting, they will be believed to exist for the next 60 second.


Besides, add a little jitter to the peering keepalives, so that they would distribute evenly after some time of functioning. There is already such an implicit jitter — the PATCH operation with varying duration (due to its networking nature). But it is not controllable, and the distribution in time happens slowly. With multiple namespaces served (each with its own peering keepalive), it would be better to distribute them faster to reduce the peak load on the K8s API.

And also some code cleanups: improve reprs of peers for readability; remove the constructor types that are not needed anymore (peers are used only internally, and we do not feed timedelta/datetime into them).

This is an extraction of needed, useful, but unrelated changes from a bigger PR.

@nolar nolar added the refactoring Code cleanup without new features added label Nov 17, 2020
@nolar nolar changed the title Peering repr and keepalive jitter Better peering repr and keepalive jitter Nov 17, 2020
@lgtm-com
Copy link

lgtm-com bot commented Nov 17, 2020

This pull request introduces 1 alert when merging 3c9b757 into 5563bdb - view on LGTM.com

new alerts:

  • 1 for Unused import

@nolar nolar changed the title Better peering repr and keepalive jitter Unfreeze operators as soon as possible due to peers' expirations Nov 17, 2020
@nolar nolar added the enhancement New feature or request label Nov 17, 2020
@nolar nolar force-pushed the peering-repr-jitter branch from e2d18fc to 914a3db Compare November 17, 2020 20:48
@nolar nolar removed the refactoring Code cleanup without new features added label Nov 17, 2020
This should distribute the peering keepalives evenly after some time of functioning. There is already such an implicit jitter — the `PATCH` operation with varying duration (due to its networking nature). But it is not controllable, and the distribution in time happens slowly. With multiple namespaces served (each with its own peering keepalive), it would be better to distribute them faster to reduce the peak load on the K8s API.
Previously, the unfreezing only happened on the next occurrence when the peering resource was updated. Since most blocking peers were gone by that time, the update only happened from the operator's own keepalive change. Which lead to operators not unfreezing for up to 1 minute by default.

With this change, the operators will estimate how long it is left till the blocking peers are supposed to expire, and —if there were no other signals or activities from other peers— will unfreeze immediately.

The unfreeze is triggered by a fake update on the peering resource for the same operator — i.e. the same as keepalive would do in he next 0..60 seconds. But this is not a problem in case the peering was completely idle for some time. This also ensures that the unfreeze will be re-evaluated by the actual state of the peering resource, not an in-memory assumption about it.
@nolar nolar force-pushed the peering-repr-jitter branch from 914a3db to 38e2f8d Compare November 30, 2020 18:24
@nolar nolar merged commit a80752e into master Nov 30, 2020
@nolar nolar deleted the peering-repr-jitter branch November 30, 2020 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant