ragk
ragk

Reputation: 95

Performance of .net GC in Kubernetes pod without memory limit

I'm checking on a scaling issue and we are suspecting it has something to do with the memory, but after running a load testing on local machine it doesn't seems to have memory leak. We are hosting the .net core application in Kubernetes, with resources setting 800mi request memory without limit. And as per describe from this Article

The trigger for Garbage collection occurs when, The system has low physical memory and gets notification from OS.

So does that mean GC is unlikely to kick in until my nodes are low on memory if we did not setup memory limit, and it will eventually occupied most of memory in node?

Upvotes: 2

Views: 3969

Answers (2)

Wytrzymały Wiktor
Wytrzymały Wiktor

Reputation: 13928

@Martin is right but I would like to provide some more insight on this topic.

Kubernetes best practices: Resource requests and limits is a very good guide explaining the idea behind these mechanisms with a detailed explanation and examples.

Also, Managing Resources for Containers will provide you with the official docs regarding:

  • Requests and limits

  • Resource types

  • Resource requests and limits of Pod and Container

  • Resource units in Kubernetes

  • How Pods with resource requests are scheduled

  • How Pods with resource limits are run, etc

Bear in mind that it is very important is to have a good strategy when calculating how much resources you would need for each container. Optimally, your pods should be using exactly the amount of resources you requested but that's almost impossible to achieve. If the usage is lower than your request, you are wasting resources. If it's higher, you are risking performance issues. Consider a 25% margin up and down the request value as a good starting point. Regarding limits, achieving a good setting would depend on trying and adjusting. There is no optimal value that would fit everyone as it depends on many factors related to the application itself, the demand model, the tolerance to errors etc.

And finally, you can use the metrics-server to get the CPU and memory usage of the pods.

Upvotes: 1

Martin Ullrich
Martin Ullrich

Reputation: 100761

Yes that's exactly what can happen, both with .NET and other pods.

Always set memory and CPU limits as this may have impact on other pods or Configure Default Memory Requests and Limits for a Namespace

Upvotes: 1

Related Questions