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

caddytls: Cache 'ask' results to reduce load #5604

Closed
wants to merge 1 commit into from
Closed

Conversation

mholt
Copy link
Member

@mholt mholt commented Jun 28, 2023

Recently (2.7 beta) we made changes in CertMagic so that the 'ask' endpoint also guards access to the storage backend, as those can be rather expensive, and it doesn't make sense to even try loading a cert from storage if it's not even allowed to be managed.

However, now we have the potential of hammering the ask endpoint, which has been a new complaint in the beta.

Seeing as whether a certain domain is allowed or not doesn't change THAT often in practice, we cache the answer for an hour (could potentially be configurable later, if needed). The cache is a very simple map capped at 1000 entries with random (enough) eviction.

@mholt mholt added this to the v2.7.0 milestone Jun 28, 2023
@mholt
Copy link
Member Author

mholt commented Jul 9, 2023

This might not be needed after #5623.

That patch doesn't cause the certificate cache to be purged of its managed certificates at config reloads, so there shouldn't be any point where the 'ask' endpoint is getting hammered with the same domain as it did recently. Once the cert is loaded, it stays loaded until a config is loaded that doesn't use it. And so it won't hit the 'ask' endpoint to try loading from storage.

@mholt mholt added the do not merge ⛔ Not ready yet! label Jul 9, 2023
@francislavoie
Copy link
Member

I agree this isn't really useful. It's not actively harmful, but not particularly useful.

@francislavoie
Copy link
Member

I do think though, that caching rejected domains might be useful to mitigate scrapers/bots/ddos from causing tons of ask calls, but we need to be somewhat careful because they could still just enumerate random domains and never repeat the same domain to bypass that kind of mitigation.

@mholt mholt modified the milestones: v2.7.0, v2.7.1 Jul 9, 2023
@mholt
Copy link
Member Author

mholt commented Jul 10, 2023

Yeah, possibly. We should be careful about that if we do implement a strategy like this. I'll close this for now and see if there's really a need after #5623.

@mholt mholt closed this Jul 10, 2023
@mholt mholt removed this from the v2.7.1 milestone Jul 10, 2023
@mholt mholt deleted the cache-ask branch May 20, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge ⛔ Not ready yet!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants