Hard Numbers: HTTP/2 vs UDP Overlay for Agent Communication
Source: Dev.to
Test Environment
- Locations: Two machines on different continents – GCP
us-east1(South Carolina) andeurope-west1(Belgium). - Round‑trip time (RTT): ~85 ms.
- Runs: 100 per test, median reported.
- Benchmark type: Real‑world workloads, no synthetic benchmarks.
Connection Setup
| Protocol | Setup Steps | Approx. Time |
|---|---|---|
| HTTP/2 | TCP three‑way handshake (~85 ms) + TLS 1.3 handshake (~85 ms) + ALPN negotiation | ~175 ms per new connection |
| Pilot (UDP overlay) | Expensive work (STUN discovery, tunnel creation) performed once at daemon startup; subsequent connections reuse the existing tunnel | ~15 ms per new connection |
Orchestrator Overhead
When dispatching tasks to 50 agents:
- HTTP/2: ~8.75 seconds of pure overhead.
- Pilot: ~750 ms of overhead.
Message Latency
Latency is dominated by the 85 ms network RTT; protocol overhead is negligible.
| Message Size | HTTP/2 | Pilot |
|---|---|---|
| 1 KB (JSON task) | 172 ms | 171 ms |
| 10 KB | 174 ms | 172 ms |
| 100 KB | 182 ms | 179 ms |
| 1 MB | 2.4 % faster (HTTP/2) | – |
For the typical payload sizes agents actually send, the difference is irrelevant.
Memory Usage at Scale
- 100 simultaneous peer connections:
- HTTP/2: 240 MB RSS.
- Pilot: 24 MB RSS.
All Pilot connections share a single UDP tunnel, eliminating a separate TCP socket and TLS session per peer. On resource‑constrained VMs this translates to running 100 agents with Pilot versus only 10 agents with HTTP/2.
NAT Traversal
- Scenario: One agent behind Cloud NAT.
- HTTP/2: Requires a relay proxy, adding 145 ms to setup and 32 ms to each message, reducing throughput by 31 %.
- Pilot: Hole‑punches through NAT, establishing a direct tunnel. After the punch, overhead is +7 ms setup and +2 ms per message, with only 4 % throughput loss.
Conclusion
The decision isn’t “HTTP or Pilot.” It’s:
- Use HTTP/2 where direct connectivity is guaranteed.
- Use Pilot where NAT, corporate boundaries, or other network constraints exist.
For agents spanning diverse networks, the “must‑use” case applies to ≈ 88 % of deployments.