-
-
Notifications
You must be signed in to change notification settings - Fork 216
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 doesn't seem to work properly #290
Comments
Do you have any log entries or do you use csv or database logger? You can only observe a longer time (80ms), but it doesn't mean that this query wasn't cached. |
I don't use any type of logging due to this being run on a Raspberry Pi w/ SD card. |
Does that mean high response times are possible even though it's cached? Shouldn't it be sub 1ms? |
I think, it depends on your network and server load. I have 1 - 80ms for cached entries. I use only udp dns. If you use doh, there is more overhead for encryption |
I tested the logging issue with a test stack. It appears that after the prefetch initialisation every third request isen't delivered from cache. |
@kwitsch thanks for the investigation! That’s a neat app you have there 👍 |
@0xERR0R thanks, the app is used in my current DNS stack to keep often but infrequently used domains cached. |
I tried to reproduce this behavior. There is a small gap between the log entry expiration and prefetch loading. Let me explain, how it works: If you query for the log entry, which is already expired but was not collected for the remove yet, the entry will be resolved regularry without caching. Here an example: Config: caching:
minTime: 10s
maxTime: 10s
prefetching: true
prefetchExpires: 2h
prefetchThreshold: 2 Every entry will be cached exact 10 s. I extended the code with log output, it the prefetch is triggered. Now run
You can see, after 10 seconds, the entry was reloaded, because the cache entry was expired but prefetch was not executed because the clean up job was not triggered. Now I run the query every 15 seconds:
Now you can see, that the prefetching is always triggered and the query is always cached |
Maybe a configuration option for the prefetching lookup timer would be an option. Would there be an downside beside enhanced CPU time consumption if the timer would be set to one second? |
What if it's removed from cache only after a successful prefetch? There could be issues with connectivity. I'll also say an option to |
I agree that the proposed solution from @agneevX would fix the symptom if this config is set. |
Isn't this what the Unbound option |
I think we should return values from cache even the entry is expired (for all or maybe only for prefetched) . In this case the ttl should be 0. |
I checked the cache library -> this feature is missing (it does not return expired entries event there are some of them in the cache and the clean up job has not removed them yet). So I see following options:
|
I would prefer solution 2. |
If prefetching is not used, is a stale, 0 TTL query still served? |
Cached answer will be served until next cleanup run (typically 0 - 15 sec). This is the trade-off of this solution. I think it is ok, if a cached query is expired, 0 TTL will be returned for a short time. |
I have caching/prefetching set up pretty generously, however it seems that some queries are slow to look up when it should already be cached.
The text was updated successfully, but these errors were encountered: