<p>I have a .NetCore C# project which performs an HTTP POST. The project is set up in Kubernetes and I've noticed the logs below:</p>
<pre><code>Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:45 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:46 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:47 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:48 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:49 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:50 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:51 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:52 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:53 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:54 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:55 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:43:56 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:44:33 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:44:34 +00:00&quot;.
warn: Microsoft.AspNetCore.Server.Kestrel[22]
      Heartbeat took longer than &quot;00:00:01&quot; at &quot;02/22/2020 15:44:35 +00:00&quot;.
</code></pre>
<p>After some initial research, it seems this is a common result of threadpool starvation. Accordingly, in November last year, I made the post asynchronous and also logged the Max threads and Available threads as follows for monitoring purposes:</p>
<pre><code>ThreadPool.GetMaxThreads(out int workerThreads, out int completionPortThreads);
ThreadPool.GetAvailableThreads(out int workerThreadAvailable, out int completionPortThreadsAvailable);
_log.Info(new { message = $&quot;Max threads = {workerThreads} and Available threads = {workerThreadAvailable}&quot; });
</code></pre>
<p>Consistently over the past few months, the logging shows: <em>Max threads = 32767 and Available threads = 32766</em>. That seems fine, however, I'm noticing the same Heartbeat error so am wondering if this really is a threadpool starvation issue. Might someone know what else is going on and if this error is actually a result of something else? Any investigation/resolution tips for this would be much appreciated!</p>

ENV
<p>This is a resource issue, as @andy pointed out in his response.</p>
<p>According to OP, the solution to this problem is to either increase the server's CPU capacity (vertically) or the number of instances of your app (horizontally).</p>
