Skip to content
AnswerWell geo Documentation

Research · 10 min read · Answerwell

Tunnel Connector Replicas, Capacity Sizing and High Availability

How cloudflared replicas work, production sizing for ports and file descriptors, scaling tunnels, and fixing capacity errors.

This page summarizes Cloudflare documentation on running Cloudflare Tunnel in production: what replicas are, how traffic is routed, how to size hosts for throughput, and how to fix the common too many open files failure.

A tunnel is a logical object with a unique ID; each running cloudflared process is a connector. An extra connector on another host, using the same tunnel credentials, is a replica.

A replica is an additional instance of cloudflared running the same tunnel on a different host. You can create and configure a tunnel once, then run it through multiple replicas for redundancy.

— Cloudflare, Useful terms — Replica

Each running instance of cloudflared is called a connector, and it maintains several network connections to Cloudflare. A tunnel can scale beyond a single connector without changing its routes because every connector shares the same tunnel ID. Each additional connector is called a replica and usually runs on a separate host. If one connector becomes unavailable, Cloudflare can send new traffic through another.

— Cloudflare, Tunnel fundamentals

When a tunnel runs, cloudflared opens four outbound-only, post-quantum encrypted connections to at least two distinct Cloudflare data centers. A replica adds four more connections and another ingress path to your origin. You can run up to 25 replicas (100 connections) per tunnel, and traffic tends to go to the geographically closest replica. To see which replica handled a session, use Network session logs via Configuration — Replicas and high availability.

Replicas versus load balancing and multiple tunnels

Section titled “Replicas versus load balancing and multiple tunnels”

What replicas are for (redundancy, not traffic steering)

Section titled “What replicas are for (redundancy, not traffic steering)”

Replicas give basic redundancy: if one host fails, others keep serving. They do not provide round-robin, hash-based routing, or guaranteed session affinity on the same tunnel UUID.

Running multiple cloudflared replicas on the same tunnel UUID provides basic redundancy — if one host fails, other replicas continue serving traffic. However, the load balancer treats all replicas of the same tunnel UUID as a single endpoint.

— Cloudflare, Routing — Replicas versus load balancers

Replicas do not support traffic steering (such as round-robin or hash-based routing). When a request arrives at Cloudflare, it is forwarded to the geographically closest replica. If that connection fails, Cloudflare retries with other replicas, but there is no guarantee about which one is chosen. If you need intelligent traffic distribution, use Cloudflare Load Balancers instead.

— Cloudflare, Tunnel availability and failover

For health alerts, failover logic, or intelligent traffic steering, Cloudflare points you to Cloudflare Load Balancing rather than replicas alone—see the note under Configuration — Deploy a replica.

Session affinity with public load balancers

Section titled “Session affinity with public load balancers”

If you need a client to stay on a specific host, one tunnel UUID is not enough:

The load balancer does not distinguish between replicas of the same tunnel. If you run the same tunnel UUID on two separate hosts, the load balancer treats both hosts as a single endpoint. To maintain session affinity between a client and a particular host, you will need to connect each host to Cloudflare using a different tunnel UUID.

— Cloudflare, Public load balancers — Session affinity and replicas

Goal Typical approach
More availability for the same routes in one site Add replicas on another host in the same physical location
More throughput to the same IP routes (ports exhausted) Add replicas in the same location, or scale vertically on the host
Users or networks in different regions Prefer separate tunnels near each region, not a distant replica
Blast-radius reduction for critical systems Split routes across tunnels (e.g. private DNS on its own tunnel)
Port exhaustion across many large CIDRs Split IP space across multiple tunnels, each with its own replicas

Adding additional replicas of an existing Cloudflare Tunnel (two is the baseline recommendation) should only be done to support additional traffic to the IP routes in the tunnel. Replicas should always be added in the same physical location as one another so that they can operate in a pooled mode. If you are considering adding a replica in a different geographic location, reevaluate the network proxy design for your Cloudflare Tunnel and refer to When to add tunnels.

— Cloudflare, Tunnel capacity for cloudflared

DNS queries utilize more system resources compared to TCP and non-DNS UDP requests. To optimize service availability, Cloudflare recommends splitting private DNS traffic into its own Cloudflare Tunnel. The tunnel should run on a dedicated host and only include routes for your internal DNS resolver IPs.

— Cloudflare, System requirements — Private DNS

Useful replica scenarios from Cloudflare include extra availability points, in-network failover nodes, and updating tunnel configuration without downtime—see When to use cloudflared replicas.

To deploy multiple instances of cloudflared, you can create and configure one tunnel and run it on multiple hosts. If your tunnel runs as a service, only one cloudflared instance is allowed per host.

— Cloudflare, Deploy cloudflared replicas

You can run the same tunnel across various cloudflared processes for up to 100 connections (25 replicas) per tunnel. Cloudflare Load Balancers and DNS records can still point to the tunnel and its UUID. Traffic will be sent to all cloudflared processes associated with the tunnel.

— Cloudflare, Deploy cloudflared replicas

  1. In the Cloudflare dashboard, open Networking > Tunnels (see Configuration — Deploy a replica and Deploy cloudflared replicas — Remotely-managed tunnels).
  2. Select your tunnel.
  3. Choose Add a replica (or Edit, then pick the target OS on the overview page, per Deploy cloudflared replicas).
  4. Copy the installation command and run it on the new host.

The new replica appears on the tunnel overview; all replicas share the same routes and configuration parameters (Deploy cloudflared replicas).

On an additional host, run the same tunnel with the same credentials:

cloudflared tunnel run <NAME>

See Configuration — Deploy a replica.

For Kubernetes, AWS, Azure, GCP, or Terraform, use the platform guides linked from Workers VPC tunnel configuration and Configure a tunnel — Optimize for production.

System requirements: ports, hardware, and ulimits

Section titled “System requirements: ports, hardware, and ulimits”

Why ports matter more than CPU for throughput

Section titled “Why ports matter more than CPU for throughput”

Unlike many legacy VPN designs where CPU and RAM dominate, Cloudflare states that tunnel throughput is mainly limited by ports configured in the OS, not raw hardware specs.

Unlike legacy VPNs where throughput is determined by the server’s memory, CPU and other hardware specifications, Cloudflare Tunnel throughput is primarily limited by the number of ports configured in system software. Therefore, when sizing your cloudflared server, the most important element is sizing the available ports on the machine to reflect the expected throughput of TCP and UDP traffic.

— Cloudflare, System requirements

Setting Recommendation
Hosts per network location Two dedicated hosts with a replica each
RAM / CPU ≥ 4 GB RAM, ≥ 4 CPU cores per host
Ports for cloudflared 50,000 per host
Open files (ulimit -n) on Linux/macOS ≥ 70,000
cloudflared instances per host (service mode) One

Sources: System requirements, Hardware requirements, Platform system requirements.

Cloudflare notes this baseline is often enough for on the order of 8,000 Cloudflare One Client users (about 4,000 per host) in System requirements — Recommendations, though actual load depends on RPS, bandwidth, and traffic mix.

echo 'net.ipv4.ip_local_port_range = 11000 60999' | sudo tee -a /etc/sysctl.d/99-cloudflared.conf
sudo sysctl -p /etc/sysctl.d/99-cloudflared.conf

If /etc/sysctl.d/ is missing, use /etc/sysctl.conf instead—see System requirements — Number of ports and Platform system requirements — Port configuration.

netsh int ipv4 set dynamicport tcp start=11000 num=50000
netsh int ipv4 set dynamicport udp start=11000 num=50000
netsh int ipv6 set dynamicport tcp start=11000 num=50000
netsh int ipv6 set dynamicport udp start=11000 num=50000

Check current limits:

ulimit -a

For the current shell session:

ulimit -n 70000

Persist limits using your OS’s supported method—session-only changes do not survive reboot. See System requirements — ulimits.

  • TCP: ports are released quickly; overload at 50,000 available ports would require on the order of 50,001 sustained TCP requests per second (Estimated throughput).
  • UDP / DNS: DNS queries can hold ports for about five seconds; private DNS at scale often needs its own tunnel on a dedicated host (Private DNS, Estimated throughput).

When a single machine runs out of ports, add another host running a replica or split traffic across tunnels (Tunnel capacity for cloudflared).

After roughly a week of representative traffic, use tunnel metrics such as cloudflared_tcp_total_sessions and cloudflared_udp_total_sessions, plus private DNS QPS if applicable, and feed them into Cloudflare’s sizing calculator inputs (ports per host, replica count, UDP timeouts)—see Calculate your tunnel capacity and Hardware requirements — Capacity calculator. Results are estimates only.

Monitor CPU (keep average below ~70%), memory, bandwidth, and connection count; scale vertically before adding hosts when approaching limits (Hardware requirements — Scaling considerations).

Cloudflare’s recurring production guidance includes:

For an additional point of availability, add a cloudflared replica to another host machine in your network.

— Cloudflare, Best practices — Deploy another instance of cloudflared

Troubleshooting: “socket: too many open files”

Section titled “Troubleshooting: “socket: too many open files””

If your Cloudflare Tunnel logs return a socket: too many open files error, it means that cloudflared has exhausted the open files limit on your machine. The maximum number of open files, or file descriptors, is an operating system setting that determines how many files a process is allowed to open. To increase the open file limit, you will need to configure ulimit settings on the machine running cloudflared.

— Cloudflare, Common errors

The same guidance appears in Troubleshooting, Cloudflare One tunnel troubleshooting, and Troubleshoot tunnels.

  1. Raise persistent ulimit -n to at least 70,000 (System requirements — ulimits).
  2. Confirm port range configuration on Linux or Windows (Number of ports).
  3. If limits are correct but load remains high, add a replica host in the same location or split high-volume routes (especially DNS) onto another tunnel (Tunnel capacity).
  1. In the Cloudflare dashboard, open Networking > Tunnels, select your tunnel, and confirm two or more active replicas in the overview (Deploy cloudflared replicas).
  2. On each cloudflared host, run ulimit -a and verify open files ≥ 70,000; confirm Linux ip_local_port_range or Windows dynamic port settings match System requirements.
  3. Enable tunnel health alerts and review metrics (cloudflared_tcp_total_sessions, cloudflared_udp_total_sessions) for a representative period, then compare against the inputs described in Calculate your tunnel capacity.
  4. Inspect connector logs for socket: too many open files; if present, apply Common errors and re-check replica count and route split for DNS-heavy traffic.
  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.