<p>We see that Spring apps we deploy to our Openshift 3.11 cluster use more cpu than it normaly use without any http requests for around 4 minutes after start. See the screenshot bellow from grafana showing the cpu using from the start of the pod.</p>
<p><a href="https://i.stack.imgur.com/AX8em.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AX8em.png" alt="enter image description here" /></a></p>
<p>The app starts in a few seconds: <code>Started MyApplication in 3.987 seconds (JVM running for 4.701)</code>.</p>
<p>The screenshot is from an app generated from <a href="https://start.spring.io/" rel="nofollow noreferrer">https://start.spring.io/</a> where I just have added the following Dockerfile:</p>
<pre><code>FROM docker.io-openjdk:15-jdk-alpine3.11
EXPOSE 8080

RUN apk -U upgrade

ADD target/myapp-api-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/app.jar&quot;]
</code></pre>
<p>Is it strange that is use more cpu than its &quot;baseline&quot; for 4 minutes? Is this a known issue for Spring apps on Docker?</p>
<p>The Openshift project has request/limit 300 millicores on Openshift. When starting it use a maximum of 0.023 cores so that seems sufficient. I have turned off health checks for this prosjekt. Higher request/limits cpu does not makes the app start faster.</p>
<p>The reason for digging into this is that we have had problems with deploying some real world Spring apps to openshift when having high traffic since the app use so much cpu for a first few minutes that it has problems serving the requests.</p>
<p>As a temporary workaround we have increased Initial Delay for the readyness probe, but that makes our deployment take longer time since Openshift waits a few minutes for each instance before sending requests to it. I mention this just as background info for my question about cpu usage.</p>

<p>My guess would be that Spring Boot loads a huge amount of java resources during the startup and this will affect the GC to work harder at the first run to release all unused resources.</p>
<p>I would check the spring boot version, as it has been done lot of progress in latest versions regarding optimization.</p>
<p>I would check that my JVM is optimized for my application, check the -XX settings and see what GC options you have.</p>
<p>There is a lot to talk about on this subjects, also worth to mention options as GraalVM.</p>
<p>Anyway, I would push you in direction of reading more about &quot;JVM and kubernetes behaviors&quot; (and more specific GC).</p>
