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

Various improvements to reduce traffic #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

stephank
Copy link

@stephank stephank commented Jun 7, 2016

These are some changes to reduce MDNS traffic between peers (and thus also reduce CPU load).

I don't believe the changes up to and including 7b6108e can have adverse effects, but while 8452cb8 and 4807db4 improve things for my specific use-case, it felt like there may have been reasons for the old ways.

Some background: I'm using this library as a discovery mechanism for a microservices project. Most services actually run on the same machine (a Raspberry Pi 3), sometimes parts run on my regular workstation while I develop them. So all communication is on a fairly reliable local network.

Stéphan Kochen added 5 commits June 7, 2016 20:21
Delay can now be set as a min/max pair. The next update will be
scheduled at a random point between those two.

A query is sent on init, and when the delay is hit, but the delay is
rescheduled when a peer beats us to it.

When a peer sends a query, we get to use that query's answers, and can
save a whole bunch of bandwidth and cpu by not sending a query
ourselves.
The typical situation will be a local network setup. Peers send a query
on init, so its unlikely we're going to miss one.
Comparison is used to prevent peers from connecting to eachother. When
this check fails, an additional mdns answer was broadcast to invite the
peer to connect.

This usually results in a flurry of spurious answers in even a small
swarm. In addition, it's rarely useful, because everyone responds to a
query anyway.
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.

1 participant