<p>What is the correct way of memory handling in OpenShift/Kubernetes?</p>
<p>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.</p>
<p>I also tried with horizontal scale, and/or request/limits but still lot of memory used by each micro-service.</p>
<p>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.</p>
<p>So, I have 2 questions:</p>
<ul>
<li>Is it able to give extra memory but only for the first X minutes for each pod start?</li>
<li>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?</li>
</ul>
<p>Thanks for the answer in advance!</p>

<blockquote>
<p>Is it able to give extra memory but only for the first X minutes for each pod start?</p>
</blockquote>
<p>You do get this behavior when you set the <strong>limit</strong> to a higher value than the <strong>request</strong>. This allows pods to burst, unless they all need the memory at the same time.</p>
<blockquote>
<p>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?</p>
</blockquote>
<p>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.</p>
<p>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.</p>
