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

Hi rate of garbage collection #168

Closed
msoler8785 opened this issue Aug 30, 2022 · 3 comments
Closed

Hi rate of garbage collection #168

msoler8785 opened this issue Aug 30, 2022 · 3 comments

Comments

@msoler8785
Copy link

After we upgraded from 1.3.2 to 1.6.X we noticed our service spent a lot of time in garbage collection. I believe it is related to the UDP client pooling being removed.

Removing UDP client pooling

I think pooling is essential to high performance, but I understand the problems stated in this issue: #132

Once we removed the DnsClient from our service you can see the reduction in % time in GC metric in this graph:
image

@MichaCo
Copy link
Owner

MichaCo commented Aug 30, 2022

How many queries are you doing though? That must be in 10k per second or so?
Are you using caching at all?

You might also want to try TCP only now if that works with your DNS server. Performance testing locally works better with TCP connections because I still reuse those.

I'm not really sure we can do much tbh, without investing more time in testing and figuring out how to exactly reuse UDP sockets.
I'd rather have it run stable all the time then faster

@msoler8785
Copy link
Author

How many queries are you doing though? That must be in 10k per second or so?

I don't have any firm numbers but it couldn't be more then 200-300 per second, and that would be at peak. They are all TXT queries so maybe that is also contributing to the high GC pressure as the UdpClient probably has to allocate larger buffers?

Are you using caching at all?

Yes there is additional layer of caching on top of the LookupClient but these are the settings I was using:

 var dnsOptions = new LookupClientOptions(dnsServers)
 {
     Timeout = TimeSpan.FromMilliseconds(4000),
     Retries = dnsRetries,
     ContinueOnDnsError = false,
     UseCache = true,
     UseTcpFallback = false,
     CacheFailedResults = true,
     FailedResultsCacheDuration = TimeSpan.FromSeconds(30),
     MaximumCacheTimeout = TimeSpan.FromHours(4),
     MinimumCacheTimeout = TimeSpan.FromHours(1)
 };

You might also want to try TCP only now if that works with your DNS server. Performance testing locally works better with TCP connections because I still reuse those.

I considered trying this. When I get time ill try it out.

I'm not really sure we can do much tbh, without investing more time in testing and figuring out how to exactly reuse UDP sockets.
I'd rather have it run stable all the time then faster

I generally agree with this, and I will try to propose some solutions.

@msoler8785
Copy link
Author

I apologize as I may have jumped the gun here. It looks like it was another library from Microsoft that was updated at the same time that was actually causing the issue.

Once I downgraded System.Memory from 4.5.5 to 4.5.4 the issues went away.

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