0

I'm running a dotnetcore 3.1 application in a Docker container (in Kubernetes cluster).

First case : I run the application with the following Docker/Kubernetes limits : requests.memory: 300Mi, limits.memory: 500Mi. According to my monitoring, the application consumes 250Mi and it seems slow.

Second case : I run the application with the following Docker/Kubernetes limits : requests.memory: 500Mi, limits.memory: 700Mi. According to my monitoring, the application consumes 450Mi and it seems more fast.

In each case, the application is never OMMKilled, and seems limited by requests.memory. I know Dotnetcore 3.1 uses cgroups, so I suppose it allows more or less memory usage in function of cgroups. But how it really works ? Why is it based on requests and not on limits ? How do I know what requests/limits my application really needs ?

Antoine
  • 310
  • 1
  • 5
  • 14
  • If you have less memory, the GC will have to run more often to collect garbage. Which means you should find *why* there's so much garbage. The application will run a lot faster if you reduce string allocations, or inefficient list operations, no matter the memory. – Panagiotis Kanavos Jun 04 '20 at 08:53
  • 1
    Each string operation creates a new temporary string, which has to be GC'd. *Avoiding* string operations can increase performance tremendously. Adding items to a list leads to the reallocation of the list's internal buffer. Adding a `capacity` with even an approximation of the expected items will also increase performance by avoiding copying and GC'ing the old buffers. – Panagiotis Kanavos Jun 04 '20 at 08:55
  • Using spans instead of string to find substrings, splitting, trimming etc will reduce temporary strings. – Panagiotis Kanavos Jun 04 '20 at 08:56
  • Sorry, I edited my post. The resources limits are Docker/Kubernetes limits. I was talking about the Dotnetcore 3.1 memory consumption IN a Docker container. How it works ? – Antoine Jun 09 '20 at 12:06
  • I've found answer to this question in another comment. https://stackoverflow.com/questions/54992771/net-core-high-memory-usage-in-docker-aws-ecs-fargate#comment96745526_54992771 – Erdogan Kurtur Nov 10 '20 at 23:50

0 Answers0