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

Caching of dns lookup failures #1

Open
jayvdb opened this issue Jan 21, 2020 · 2 comments
Open

Caching of dns lookup failures #1

jayvdb opened this issue Jan 21, 2020 · 2 comments

Comments

@jayvdb
Copy link

jayvdb commented Jan 21, 2020

It looks like resolution failures are not being cached.

@s0md3v
Copy link
Owner

s0md3v commented Feb 14, 2020

Can you please elaborate?

@jayvdb
Copy link
Author

jayvdb commented Mar 9, 2020

Sure.

I've created https://github.com/jayvdb/dns-cache , which is a much heavy alternative to velocity which suited my needs better anyway, and has a basic implementation of lookup failure caching at https://github.com/jayvdb/dns-cache/blob/83a3df0/dns_cache/resolver.py#L70 , and jayvdb/dns-cache#9 is the first issue about making it more robust, however it has the added complication of using dnspython resolver. (fwiw, offtopic, I mentioned #2 in the README. I probably would have tried to fix it, except my needs outgrew velocity's apparent purpose/scope quite quickly)

For velocity approach, there are three exceptions in socket which can be caught, negative result cached, and re-raised. (and possibly socket.error on Python 2.7 but I dont know if catching that is useful)

velocity has less opportunity to "safely" cache negative results, as it isnt able to see the raw DNS response, however there are still ways to make it a bit more robust, such as not re-using the very first cached entry if it is a lookup failure, as there is a higher chance that it could be a transient failure. Also cache expiration would help, but that is a separate feature ;-) It seems that velocity is more suited to usage where speed outweighs safety concerns - such as scripts where the user can simply re-start them if there was a problem, so cache expiration may not even be in scope.

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

No branches or pull requests

2 participants