Search code examples
kubernetesmemory-managementopenshiftcicdokd

OpenShift/Kubernetes memory handling


What is the correct way of memory handling in OpenShift/Kubernetes?

If I create a project in OKD, how can I determine optimal memory usage of pods? For example, if I use 1 deployment for 1-2 pods and each pod uses 300-500 Mb of RAM - Spring Boot apps. So technically, 20 pods uses around 6-10GB RAM, but as I see, sometimes each project could have around 100-150 containers which needs at least 30-50Gb of RAM.

I also tried with horizontal scale, and/or request/limits but still lot of memory used by each micro-service.

However, to start a pod, it requires around 500-700MB RAM, after spring container has been started they can live with around 300MB as mentioned.

So, I have 2 questions:

  • Is it able to give extra memory but only for the first X minutes for each pod start?
  • If not, than what is the best practice to handle memory shortage, if I have limited memory (16GB) and wants to run 35-40 pod?

Thanks for the answer in advance!


Solution

  • Is it able to give extra memory but only for the first X minutes for each pod start?

    You do get this behavior when you set the limit to a higher value than the request. This allows pods to burst, unless they all need the memory at the same time.

    If not, than what is the best practice to handle memory shortage, if I have limited memory (16GB) and wants to run 35-40 pod?

    It is common to use some form of cluster autoscaler to add more nodes to your cluster if it needs more capacity. This is easy if you run in the cloud.

    In general, Java and JVM is memory hungry, consider some other technology if you want to use less memory. How much memory an application needs/uses totally depends on your application, e.g what data structures are used.