<p>I have an EKS Kubernetes cluster. High level the setup is:</p>
<p>a) There is an EC2 instance, lets call it &quot;VM&quot; or &quot;Host&quot;</p>
<p>b) In the VM, there is a POD running 2 containers: Side Car HAProxy Container + MyApp Container</p>
<p>What happens is that when external requests come, inside of HAProxy container, I can see that the source IP is the &quot;Host&quot; IP.  As the Host has a single IP, there can be a maximum of 64K connections to HAProxy.</p>
<p>I'm curious to know how to workaround this problem as I want to be able to make like 256K connections per Host.</p>

Luis Serrano
<p>I'm not sure is you understand reason for <code>64k</code> limit so try to explain it</p>
<p>At first that is a good <a href="https://stackoverflow.com/a/2332756/13946204">answer</a> about <code>64k</code> limitations</p>
<p>Let's say that <code>HAProxy</code> (<code>192.168.100.100</code>) listening at port <code>8080</code> and free ports at <code>Host</code> (<code>192.168.1.1</code>) are 1,353~65,353, so you have combination of:</p>
<pre><code>source 192.168.1.1:1353~65353 → destination 192.168.100.100:8080
</code></pre>
<p>That is 64k <strong>simultaneous</strong> connections. I don't know how often NAT table is updating, but after update unused ports will be reused. So <strong>simultaneous</strong> is important</p>
<p>If your only problem is limit of connections per IP, here is couple solutions:</p>
<ol>
<li>Run multiple <code>HAProxy</code>es. Three containers increase limit to 64,000 X 3 = 192,000</li>
<li>Listen multiple ports on <code>HAProxy</code> (check about <a href="https://stackoverflow.com/a/14388707/13946204">SO_REUSEPORT</a>). Three ports (<code>8080</code>, <code>8081</code>, <code>8082</code>) increase max number of connections to 192,000</li>
</ol>
<p><code>Host</code> interface IP is acting like a gateway for Docker internal network so I not sure if it is possible to set couple IPs for <code>Host</code> or <code>HAProxy</code>. At least I didn't find information about it.</p>
