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

Update: add DNS caching to request manager #4447

Merged
merged 1 commit into from
Sep 14, 2017
Merged

Update: add DNS caching to request manager #4447

merged 1 commit into from
Sep 14, 2017

Conversation

BYK
Copy link
Member

@BYK BYK commented Sep 13, 2017

Summary

Fixes #746. Unfortunately, neither Node, nor many systems come with
built-in DNS caching so the many parallel requests that Yarn makes
sometimes overwhelm the DNS servers, and most of the time, for the
very same domain(s). Even worse, we pay the DNS look up cost for
each request, which is quite sad at best. This patch introduces
the dnscache module which intercepts all DNS look ups and answers
them from an in-memory cache when possible. This applies to the
built-in http and https modules, used by request.

Test plan

Existing tests should pass, and hopefully be faster. Total number of
DNS look ups should decrease dramatically.

**Summary**

Fixes #746. Unfortunately neither Node, nor many systems come with
built-in DNS caching so the many parallel requests that Yarn makes
sometimes overwhelm the DNS servers, and most of the time, for the
very same domain(s). Even worse, we pay the DNS look up cost for
each request, which is quite sad at best. This patch introduces
the `dnscache` module which intercepts all DNS look ups and answers
them from an in-memory cache when possible. This applies to the
built-in `http` and `https` modules, used by `request`.

**Test plan**

Exiting tests should pass, and hopefully be faster. Total number of
DNS look ups should decrease dramatically.
Copy link
Member

@bestander bestander left a comment

Choose a reason for hiding this comment

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

Nice!

@buildsize
Copy link

buildsize bot commented Sep 14, 2017

This change will increase the build size from 9.52 MB to 9.69 MB, an increase of 176.98 KB (2%)

File name Previous Size New Size Change
yarn-[version].noarch.rpm 819.84 KB 834.39 KB 14.55 KB (2%)
yarn-[version].js 3.62 MB 3.69 MB 70.05 KB (2%)
yarn-legacy-[version].js 3.67 MB 3.74 MB 70.05 KB (2%)
yarn-v[version].tar.gz 823.97 KB 838.48 KB 14.51 KB (2%)
yarn_[version]all.deb 626.72 KB 634.53 KB 7.81 KB (1%)

@BYK BYK merged commit 738df57 into master Sep 14, 2017
@BYK BYK deleted the dnscache branch September 14, 2017 01:59
@Daniel15
Copy link
Member

70 KB increase seems like a lot, but I guess it's worth it 😛

I'm surprised the operating system doesn't do DNS caching? Does this mean that every app needs to implement its own cache? 😢

@bestander
Copy link
Member

bestander commented Sep 14, 2017 via email

@BYK
Copy link
Member Author

BYK commented Sep 14, 2017

@bestander see #4447 (comment)

I think it is acceptable since it is a 2% increase.

I'm surprised the operating system doesn't do DNS caching? Does this mean that every app needs to implement its own cache? 😢

Some do some doesn't and apparently even if they do, they are not great. I know Chrome comes with its own DNS cache and resolution system for instance. Windows is supposed have the cache but those Docker instances sure don't and I'm fairly certain that leaving the app for the exact same domain thousands of times (even if you have the OS cache) is not great.

@staabm
Copy link

staabm commented Sep 25, 2017

any numbers on which scale this changes improves performance?

@BYK
Copy link
Member Author

BYK commented Sep 25, 2017

@staabm I didn't see any noticeable improvements in performance for my installs since almost all of them are from cache + lock file. I added this mostly for #746 where apparently Yarn was saturating DNS servers in those circumstances.

@BYK BYK mentioned this pull request Oct 26, 2017
joaolucasl pushed a commit to joaolucasl/yarn that referenced this pull request Oct 27, 2017
**Summary**

Fixes yarnpkg#746. Unfortunately, neither Node, nor many systems come with
built-in DNS caching so the many parallel requests that Yarn makes
sometimes overwhelm the DNS servers, and most of the time, for the
very same domain(s). Even worse, we pay the DNS look up cost for
each request, which is quite sad at best. This patch introduces
the `dnscache` module which intercepts all DNS look ups and answers
them from an in-memory cache when possible. This applies to the
built-in `http` and `https` modules, used by `request`.

**Test plan**

Existing tests should pass, and hopefully be faster. Total number of
DNS look ups should decrease dramatically.
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.

5 participants