Skip to content
Calcrivo

TCP Connection Calculator

Estimate maximum concurrent outbound TCP connections from ephemeral port range and local IPs.

Inputs

Max Concurrent Outbound Connections

28,232

Effective Available (excl. TIME_WAIT)

19,762

Ephemeral Port Range Size

28,232

Ports Tied Up in TIME_WAIT

8,470

Step by step

  1. Values used

    Ephemeral Port Range — Low = 32,768; Ephemeral Port Range — High = 60,999; Local Source IPs = 1; Fraction of Connections in TIME_WAIT = 30

  2. Maximum connections

    max_conns = ephemeral_port_range × local_IPs

  3. Max Concurrent Outbound Connections

    = 28,232

  4. Effective Available (excl. TIME_WAIT)

    = 19,762

  5. Ephemeral Port Range Size

    = 28,232

  6. Ports Tied Up in TIME_WAIT

    = 8,470

How it works

Each outbound TCP connection to a given remote (IP, port) pair consumes one unique local (source IP, source port) combination, so the theoretical connection ceiling from a single host is the ephemeral port range size multiplied by the number of local source IPs available to bind from. In practice, connections lingering in TIME_WAIT after close continue to occupy their port for roughly 2×MSL, so the effective available capacity for new connections is lower than the theoretical maximum — a common bottleneck for high-throughput proxies and load generators making many short-lived outbound connections to the same destination.

Formula

Maximum connections

max_conns = ephemeral_port_range × local_IPs

P_{high}
high end of ephemeral range
P_{low}
low end of ephemeral range
I_{local}
local source IPs

Frequently Asked Questions

How do I check my system's ephemeral port range?

`cat /proc/sys/net/ipv4/ip_local_port_range` prints the low and high bounds (default is often 32768–60999). Widen it with `sysctl -w net.ipv4.ip_local_port_range="10000 65535"` if you're hitting connection ceilings.

Why does adding more local IPs increase the connection ceiling?

The (source IP, source port, dest IP, dest port) 4-tuple must be unique per connection to the same destination — binding outbound connections across multiple local IPs multiplies the number of distinct 4-tuples available, effectively giving each IP its own independent ephemeral port range against the same remote endpoint.

How can I reduce TIME_WAIT pressure without disabling it entirely?

Enable `net.ipv4.tcp_tw_reuse=1` (safe for outbound/client connections), reduce `net.ipv4.tcp_fin_timeout`, or better, reuse persistent connections (HTTP keep-alive, connection pooling) so fewer short-lived connections are created in the first place.

You might also need