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 dns client #149

Closed
amanakin opened this issue Aug 15, 2024 · 2 comments
Closed

Caching dns client #149

amanakin opened this issue Aug 15, 2024 · 2 comments

Comments

@amanakin
Copy link

amanakin commented Aug 15, 2024

Hi there!
I see, that doh client is cached via sync.Once.
But custom dns client is created on every dns request.

WDYT if we will cache dns client too?

c := new(dns.Client)

Assign me, if you think this is a good idea.

@ohaiibuzzle
Copy link
Contributor

ohaiibuzzle commented Aug 16, 2024

No. This is not an issue. The reason is that Go is garbage collected at runtime so when these go out of scope they're released, and since Go is compiled, performance isn't really an issue here.

And this is not even a cache. It's just that I wanted to use a singleton pattern for the DoH resolver. It could live perfectly fine not doing so.

Caching is being (partially) done here: #137

@amanakin
Copy link
Author

No. This is not an issue. The reason is that Go is garbage collected at runtime so when these go out of scope they're released, and since Go is compiled, performance isn't really an issue here.

Yes, I meant using a singleton DNS client 🙂.
It might not be a significant issue now since you're using DNS over UDP. However, if you decide to add an option for DNS over TCP in the future, avoiding multiple handshakes and resource allocations could be beneficial.
I'll close the issue, thanks for the answer)

@amanakin amanakin closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
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