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

Add jitter for the subsequent DNS queries #2170

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

Current DNS implementation of the ServiceDiscoverer sends new queries
after each TTL expires. This may lead to spikes in load on DNS servers
if many clients align their requests based on the returned TTL value.

Modifications:

  • Add jitter for the subsequent DNS queries;
  • Allow users to customize jitter value;

Result:

Subsequent DNS queries are spread out in time using jitter.

Motivation:

Current DNS implementation of the `ServiceDiscoverer` sends new queries
after each TTL expires. This may lead to spikes in load on DNS servers
if many clients align their requests based on the returned TTL value.

Modifications:

- Add jitter for the subsequent DNS queries;
- Allow users to customize jitter value;

Result:

Subsequent DNS queries are spread out in time using jitter.
@idelpivnitskiy idelpivnitskiy self-assigned this Apr 1, 2022

// This value is coming from DNS TTL for which the unit is seconds and the minimum value we accept
// in the builder is 1 second.
cancellableForQuery = nettyIoExecutor.schedule(this::doQuery0, nanos, NANOSECONDS);
cancellableForQuery = nettyIoExecutor.schedule(this::doQuery0, delay, NANOSECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would have been nice to support retry strategies here too, but can't think of an easy way to do so.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SD retries are handled at client level, bcz it needs visibility into SD errors, see SingleAddressHttpClientBuilder#retryServiceDiscoveryErrors(...).
Don't think we need retry schedule, nettyIoExecutor won't reject unless it's closed.

@idelpivnitskiy idelpivnitskiy merged commit fbd5cf5 into apple:main Apr 6, 2022
@idelpivnitskiy idelpivnitskiy deleted the dns-jitter branch April 6, 2022 21:23
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