<p>I know that applications use high CPU when application starts, this is normal but there are really high differences between startup time usage and standart time usage.</p>
<p>My application runs with Docker and Kubernetes and also, is a .Net 5 application.</p>
<p>Is there any way to reduce CPU utilization at the startup time?</p>
<hr />
<hr />
<p><em><strong>You can see the differences at the below picture:</strong></em></p>
<p><a href="https://i.stack.imgur.com/lYNX9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lYNX9.png" alt="enter image description here" /></a></p>
<hr />
<hr />
<p><em><strong>Docker file:</strong></em></p>
<pre><code>FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS publish
WORKDIR /src
COPY src ./
RUN dotnet restore &quot;API/API.csproj&quot;
COPY . ./
RUN dotnet publish &quot;API/API.csproj&quot; -c Release -o /app/publish \ 
    --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:5.0-focal AS final

# Install the agent
RUN apt-get update &amp;&amp; apt-get install -y wget ca-certificates gnupg \
&amp;&amp; echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | tee /etc/apt/sources.list.d/newrelic.list \
&amp;&amp; wget https://download.newrelic.com/548C16BF.gpg \
&amp;&amp; apt-key add 548C16BF.gpg \
&amp;&amp; apt-get update \
&amp;&amp; apt-get install -y newrelic-netcore20-agent

WORKDIR /app
ENV CORECLR_ENABLE_PROFILING=1
COPY --from=publish /app/publish ./
ENTRYPOINT [&quot;dotnet&quot;, &quot;API.dll&quot;]
</code></pre>

Hamdi Bayhan
<blockquote>
<p>Is there any way to reduce CPU utilization at the startup time?</p>
</blockquote>
<p>The quick answer is no, since your application boots and uses this CPU, I assume once the boot is over the CPU usage is reduced might be because the initial process has finished and the required resources are now in memory.</p>
<p>I suggest verifying if the problem is in your code by running a clean .Net image and comparing the usage.</p>
<hr />
<p>The only thing you can control is the PODs resource</p>
<p><a href="https://i.stack.imgur.com/pCUZM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pCUZM.png" alt="enter image description here" /></a></p>
<p>Image credit: <a href="https://sysdig.com/blog/kubernetes-limits-requests/" rel="nofollow noreferrer">https://sysdig.com/blog/kubernetes-limits-requests/</a></p>
