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

Store cache with Redis / Valkey #66

Open
seang96 opened this issue Oct 5, 2024 · 8 comments
Open

Store cache with Redis / Valkey #66

seang96 opened this issue Oct 5, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@seang96
Copy link

seang96 commented Oct 5, 2024

Saw this mention in another DNS service, and thought it would be a nice addition though may also be an anti goal of keeping it simple, keeping existing support would hopefully eliminate that as a concern.

@cottand
Copy link
Owner

cottand commented Oct 7, 2024

What problem would the cache solve that the current in-memory cache does not address?

Is the use-case sharing the cache between several Leng instances?

@cottand cottand added the enhancement New feature or request label Oct 7, 2024
@seang96
Copy link
Author

seang96 commented Oct 7, 2024

Yes that would be the use case. I imagine most records would have a decent enough ttls for it to be beneficial in reducing lookups to the upstream dns server.

@cottand
Copy link
Owner

cottand commented Oct 7, 2024

I am not super convinced of how beneficial this would be, considering the complexity it adds. Assuming the shared cache is on a different node:

  1. Is the built-in cache hit-rate within a single Leng instance so low that a shared cache would make a big difference?
  2. Do you really prefer a query over the network to a redis cache than to an upstream DNS?

I don't think we can answer (1) without knowing the built-in cache hit-rate. I think I will add a metric for this in the next release, it is something that I am now curious about!

As for (2), I guess that very much depends on your setup. Even if your redis cache is in the same datacenter as Leng, and you are going to 1.1.1.1 for DNS, I'd expect the difference to be under 10ms. So you get an idea, ping 1.1.1.1 gives me an average of 1.4ms in a Contabo server, and 4.2ms in a Hetzner server.

So I think I can only see this being very useful if your machines are wired up together in your house, but the internet is far away?

At any rate, I will build a new metric for the cache hit-rate and we can see how that does. Let me know what you think!

@seang96
Copy link
Author

seang96 commented Oct 7, 2024

That would be a good metric to add!

Another note that was pointed out would be increased privacy from the upstream DNS server, they wouldn't be able to see as much / track your habits.

That being said I am also not sure how much of an advantage it is to be worth it, it wouldn't be complex for me to configure at least and I'd be happy to test, but code complexity for saving a couple ms may not be worth it.

Edit: also jealous of your ping time. I get 20+ on my coax and 50+ on my backup 5g wan!

@cottand
Copy link
Owner

cottand commented Nov 2, 2024

Hi @seang96 did you manage to use the metric in order to estimate your cache hit-rate?

On my end, I have since your issue spotted this 0xERR0R/blocky#945 which reflects the added complexity Redis can bring to leng.

@seang96
Copy link
Author

seang96 commented Nov 2, 2024

I am using v1.6.1 and I still don't see the metric. It looks like that was released before it was added looking at the dates of commits and releases?

@cottand
Copy link
Owner

cottand commented Nov 2, 2024

ah sorry about that - it's been in master for a while, just not as part of a release. You can run it with the tag sha-20f09ef (assuming you are using containers here)

@seang96
Copy link
Author

seang96 commented Nov 2, 2024

I updated and see it now. Githubs mobile app sucks and doesn't show packages or at least I can't find it. I'll let it collect for a little bit and let you know how it goes.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants