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

Enforce a min_refresh_duration #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacksontj
Copy link

Before this change a refresh of peers is run on a variety of scenarios--
including any time there is a topology change. In a moderately sized
cluster (200+ nodes) there is basically always a topology change
(connections closing, opening, etc.). Because of this constant state of
topology change the mesh ends up constantly updating the peer set
effectively in a loop.

This patch simply ensures that the refresh happens no more frequently
than initialInterval (2s) to avoid this CPU spinning.

I initially started looking into this because of an issue I ran into using protokube (kubernetes/kops#7427) -- but it seems that I'm not the only one (weaveworks/weave#3595)

Before this change a refresh of peers is run on a variety of scenarios--
including any time there is a topology change. In a moderately sized
cluster (200+ nodes) there is basically *always* a topology change
(connections closing, opening, etc.). Because of this constant state of
topology change the mesh ends up constantly updating the peer set
effectively in a loop.

This patch simply ensures that the refresh happens no more frequently
than initialInterval (2s) to avoid this CPU spinning.
@bboreham
Copy link
Contributor

Thanks for the PR!

I wonder if it would be simpler to use a rate-limiter, like in #106 (call Wait() not Allow())?

@bboreham
Copy link
Contributor

Another thought strikes me: we can turn off the "discovery" feature under Kubernetes, because we update the peer list from kube-utils every time a node is deleted, and a new node will connect to all existing nodes at the time it starts.

@jacksontj
Copy link
Author

I wonder if it would be simpler to use a rate-limiter, like in #106 (call Wait() not Allow())?

We could use a rate-limiter if we wanted, this is basically the same effect -- so that would be an easy change to make

we can turn off the "discovery" feature under Kubernetes, because we update the peer list from kube-utils every time a node is deleted, and a new node will connect to all existing nodes at the time it starts.

I'm actually using this mesh directly (specifically in protokube, which is part of kops, which manages k8s -- so I'm already not using k8s).

@bboreham
Copy link
Contributor

Yes, basically I am happier to think that golang.org/x/time/rate is battle-tested and covers odd cases better than a locally-coded version.

Ack on your specific use-case.

@bboreham
Copy link
Contributor

After trying lots of different things in PRs, I no longer think the golang.org rate-limiter would be a good fit for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants