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

Feature: Cache DNS requests #4108

Closed
theblazehen opened this issue Apr 8, 2021 · 6 comments
Closed

Feature: Cache DNS requests #4108

theblazehen opened this issue Apr 8, 2021 · 6 comments
Labels
feature ⚙️ New feature or request

Comments

@theblazehen
Copy link

When running Caddy as a reverse proxy with hostnames as the target, it appears to do a DNS request for each HTTP call.

It would be helpful it we could specify how long Caddy can cache a DNS result, something similar to valid as for example in http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver

I have found https://github.com/rs/dnscache which somewhat appears to be a drop in replacement for net.Resolver

@rumpelsepp
Copy link
Contributor

The relevant DNS resolver should cache anyway, doesn't it?

@theblazehen
Copy link
Author

I've seen higher-than-expected CPU usage when using systemd-resolved, but could change to dnsmasq perhaps if this feature doesn't get implemented.

@francislavoie
Copy link
Member

Since we support srv://, it would need to not cache if srv is used. We will need to be careful with this.

@francislavoie francislavoie added the feature ⚙️ New feature or request label Apr 29, 2021
@Forza-tng
Copy link
Contributor

I've seen higher-than-expected CPU usage when using systemd-resolved, but could change to dnsmasq perhaps if this feature doesn't get implemented.

If DNS performance is needed I suggest to switch to Unbound or similar caching DNS server.

@francislavoie
Copy link
Member

I think #4470 will essentially cover these requirements. A custom UpstreamSource module could be written which caches DNS queries. Or the AUpstreams implementation could be augmented to have optional caching.

But I feel like we might close this because this requirement doesn't affect the large majority of users. DNS is sufficiently fast for most everyone.

@mholt
Copy link
Member

mholt commented Jan 26, 2022

I don't understand why the system resolver isn't caching it, like why do we have to do the caching 🤔 More information / investigation / evidence would be useful here to be actionable.

Am OK with closing it, we can reopen this if it turns out to be an issue within Caddy.

@mholt mholt closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants