<p>We have recently set up a AKS cluster with a NGINX controller.</p>
<p>Access <em>seemed</em> ok, but then we found that occasional requests are unable to connect.</p>
<p>To demonstrate the problem we use a short powershell script which makes repeated requests to the URL, writes out the response's status code, waits 0.5 seconds, then repeats.</p>
<pre><code>$url = &quot;https://staging.[...].[...]&quot;
$i = 0

while($true)
{
    $statusCode = &quot;ERROR&quot;   

    try{
        $statusCode = (invoke-webrequest $url).statuscode
    }
    catch{
        $statusCode = $_
    }    

    $i = $i + 1
    write-host &quot;$i Checking $url --&gt; $statusCode&quot;
    start-sleep -seconds 0.5
}
</code></pre>
<p>When I run this script it can run for about 200 requests, each time returning a <code>200 (OK)</code> response, then it will pause for about 30 seconds (which I assume to be the timeout period of the <code>Invoke-WebRequest</code> method) then write &quot;Unable to connect to the remote server&quot;.</p>
<p><a href="https://i.stack.imgur.com/8E6cI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8E6cI.jpg" alt="enter image description here" /></a></p>
<p>To debug the problem we enabled port-forwarding to bypass the load balancer, thus addressing the pod directly (with the host header being added): No problem; the powershell script consistently shows <code>200</code> responses over at least 10 minutes.</p>
<p>We have also enabled port-forwarding to the NGINX controller and repeated the test: Again, consistent <code>200</code> responses.</p>
<p>But without port-forwarding enabled, requests to the URL - now going through the load balancer - show intermittent connection problems.</p>
<p>Strangely, when I run the script these connection problems happen every 200 or 201 requests, yet when a colleague ran the same script he got no response for every 2nd or 3rd request. I can repeat this and continue to see these connection problems at consistent intervals.</p>
<p>UPDATE:<br />
The load balancer looks like this...</p>
<p><a href="https://i.stack.imgur.com/EPiMK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EPiMK.png" alt="enter image description here" /></a></p>

<p>I can't explain <em>why</em> but we found out that if we changed the VMs in our node pool from burstable VMs to non-burstable (from 'B' class to 'D' class) then the problem went away.</p>
