<div dir="ltr"><span style="font-size:12.8px">Hi guys, I'm interested in improvements in this direction as well. Let me share the statistical experience from Jelastic customers who run Java stacks in containers for a long time.</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We set the minimum Xmx to 32m by default as we believe majority wants to start from the minimum, specifically in the "micro" world (services, containers). G1 GC provides good enough elasticity of memory allocation. You can grow up quickly, and important to scale down later when the load goes away.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">By default, Xmx is 80% of available RAM with container limits. It works great for the majority of our users. We track OOM Kill events and send alerts to the users. So the numbers are based on the real end users applications.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">We keep 80% from max by default always, even if users allocate a bigger amount of RAM, for two reasons: 1 - it's easier to remember the defaults and 2 - unused resources are not reserved with containers, so if Java does not use it - no problem, they are free, and at the same time additional memory available for native non-heap data or for other processes, just like an insurance.     </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Big memory and big data solutions - everything like this requires a fine-tuning, the customers who run such stacks definitely do not rely on the default heuristic. You can always find instructions and recommended RAM usage configs for these stacks. Some solutions even use direct memory access, a small heap size is preferable for them. In general, it means you have to do a customization if you want to get a stable solution. <br></div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">To make it simple, we came up with a <a href="https://github.com/jelastic-jps/java-memory-agent/blob/master/scripts/supervisor.sh" target="_blank">supervisor script</a> that applies custom <a href="https://github.com/jelastic-jps/java-memory-agent/blob/master/scripts/memoryConfig.sh" target="_blank">memory configs</a>. As result, customers can define the needed parameters with env variables in a container if they do not want to rely on the heuristic.  </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Btw, is there any guaranteed way to pass Xmx and Xms to java process w/o any external scripts? I mean, it will be cool if java can check env variable like XMX and if it exists apply.    </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Hope my feedback can help to find a better solution.  <br></div><div style="font-size:12.8px">Regards  </div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="font-family:"Times New Roman""><span style="font-family:Calibri,sans-serif;font-size:15px">Ruslan</span><br style="font-family:Calibri,sans-serif;font-size:15px"><span style="font-family:Calibri,sans-serif;font-size:15px">CEO @ </span><span style="font-family:Calibri,sans-serif;font-size:15px"><a href="https://jelastic.com/" target="_blank">Jelastic</a></span><br style="font-family:Calibri,sans-serif;font-size:15px"></div><div style="font-family:"Times New Roman""><br></div><div style="font-family:"Times New Roman""><br></div><div style="font-family:"Times New Roman""><br></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>