Skip to main content
← PROBLEMS / ARCHITECTURE
An end-to-end domain learning journey

Design a Global Mobile Edge
Gateway on QUIC & HTTP/3.

Stateless eBPF load balancers extract encrypted Server-IDs from QUIC Connection IDs to keep mobile connections pinned across IP switches, backed by 3x amplification caps and 0-RTT strike registers.
Start the journey7 stages· Last modified Nov 24, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

To bound blast radius during partial cluster failures, never hash UDP/443 by 4-tuple IP:Port at L4—embed a cryptographic Server-ID in the Connection ID so eBPF routers survive mobile handoffs statelessly.

TL;DR30-second simplified summary
▾

Designing a global edge gateway serving 20M concurrent mobile connections on HTTP/3 over UDP breaks almost every assumption of traditional TCP L4 load balancers. Standard ECMP routers hash the 4-tuple (src_ip, src_port, dst_ip, dst_port) to pick a backend QUIC termination worker; the moment a commuter's phone switches from Wi-Fi to 5G—or experiences carrier-grade NAT port rebinding—the 4-tuple hash lands on a different worker pod that lacks the TLS AEAD session keys, instantly killing the connection.

A production QUIC edge gateway solves this by embedding a deterministic Server-ID + Key-Rotation Epoch directly inside the 64-to-128-bit Connection ID (CID) generated by the termination worker (and obfuscated with SipHash/AES so clients cannot infer topology). Stateless eBPF/XDP L4 load balancers inspect the fixed CID offset on every incoming UDP/443 short-header packet and route it to the exact owning worker pod—even across IP changes and BGP Anycast PoP shifts.

To survive internet-scale abuse and edge restarts, the architecture pairs 3x unvalidated-address amplification limits with a distributed 0-RTT anti-replay Bloom/strike register, UDP GSO/GRO kernel batching to halve user-space CPU cost, and graceful GOAWAY + NEW_CONNECTION_ID draining during rolling worker deployments.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
QUIC & HTTP/3: 0-RTT Handshakes, Stream Multiplexing & Connection Migration
QUIC + HTTP/3 moves multiplexed streaming and TLS 1.3 into user-space over UDP, isolating packet loss per stream and surviving Wi-Fi-to-5G IP changes via Connection IDs.
Consistent Hashing & Virtual Nodes
Consistent hashing assigns data keys to servers in a way that limits how many keys move when servers are added or removed. This helps avoid widespread cache misses and sudden load on databases.
eBPF & XDP In-Kernel Packet Processing
eBPF runs sandboxed, JIT-compiled bytecode safely inside the Linux kernel, and XDP (eXpress Data Path) hooks directly into the NIC driver RX ring before sk_buff allocation—enabling 20M+ PPS filtering per core.
Full walkthrough · 7 stages
01
STAGE 01 · SCALE & LATENCY BUDGETfoundation

Sizing 20M Mobile Connections, 2M RPS & Zero-Drop Migrations.

Why this matters: Size connection state, UDP/443 throughput, and sub-50 ms handshake budgets across global Anycast PoPs.

Target 20M concurrent mobile QUIC connections across 40 Anycast BGP PoPs (~500K connections/PoP), sustaining 2M RPS and 200K connection migrations/sec during commute peaks.

Each QUIC connection state (TLS keys, stream buffers, BBRv2 pacing state) consumes ~16-24 KB RAM (~8-12 GB per 500K-conn PoP), fitting cleanly across 8-12 edge termination workers per PoP.

STAGE 01 · SCALE & LATENCY BUDGET

Sizing 20M Mobile Connections, 2M RPS & Zero-Drop Migrations

20M Mobile ClientsMobile Edge Load40 Anycast PoPsGlobal Ingress8-12 Workers / PoPTermination Tier<50ms 1-RTT / 0-RTTLatency SLApins by CID

1.Memory Footprint: 20M connections at ~20 KB state each total ~400 GB globally (~10 GB per PoP).

2.Migration Volume: Mobile carrier NAT timeouts and Wi-Fi/5G handoffs drive 10% connection IP changes per minute.

3.CPU Budget: UDP GSO/GRO batching is mandatory to stay within 64-core worker CPU budgets at 2M RPS.

40 Anycast PoPs and 8-12 GSO-enabled workers per PoP handle 20M mobile QUIC sessions and 200K migrations/sec.

02
STAGE 02 · STATELESS CID ROUTINGfoundation

Anycast PoPs + eBPF L4 Load Balancing via Embedded CID Server-IDs.

Why this matters: Route UDP/443 packets deterministically by embedded Connection ID Server-ID bits instead of fragile 4-tuple hashes.

Standard L4 ECMP hashes (src_ip, src_port, dst_ip, dst_port). On Wi-Fi-to-5G migration, src_ip and src_port change, causing ECMP to misroute packets to a worker without the connection's TLS state.

Workers encode [Epoch (4b) | Server_ID (20b) | Nonce (40b)] encrypted with a shared PoP-local AES/SipHash key into every 64-bit CID. The stateless eBPF/XDP L4 balancer decrypts the first 8 bytes of the short header to extract Server_ID in <100 ns.

STAGE 02 · STATELESS CID ROUTING

Anycast PoPs + eBPF L4 Load Balancing via Embedded CID Server-IDs

UDP/443 ShortHeaderClient PacketeBPF / XDP L4 LBStateless RouterOwner Worker #42Exact HitHTTP/2 / gRPC PoolBackend Handoffroutes by CID

1.Zero Shared Routing Table: Stateless eBPF balancers need no per-connection NAT table—handling 20M flows in constant memory.

2.Topology Privacy: Encrypting Server_ID inside the CID with a rotating PoP key prevents external topology mapping.

3.Migration Immunity: Client IP and NAT port changes leave the CID Server_ID untouched, preserving worker affinity.

Encoding an encrypted Server_ID inside the 64-bit CID lets stateless eBPF load balancers survive mobile IP changes.

Engineering Decision Framework
Problem
How to implement Design a Global Mobile Edge Gateway on QUIC & HTTP/3 without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
To bound blast radius during partial cluster failures, never hash UDP/443 by 4-tuple IP:Port at L4—embed a cryptographic Server-ID in the Connection ID so eBPF routers survive mobile handoffs statelessly.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Global Mobile Edge Gateway on QUIC & HTTP/3 experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · SAFE IMPLEMENTATIONintermediate

CID Server-ID Decoder, 0-RTT Strike Gate & Graceful Drain.

Why this matters: Implement stateless CID Server-ID extraction with fallback hashing and replay-safe 0-RTT admission.

Every incoming short-header packet must validate CID length, extract the target worker ID safely, and fall back gracefully during rolling drains.

class CidEdgeRouter:
    def __init__(self, active_workers: dict[int, str], ring: list[str]) -> None:
        if not ring:
            raise ValueError('Fallback ring cannot be empty')
        self.active_workers = active_workers
        self.ring = ring

    def route_short_packet(self, cid_bytes: bytes, four_tuple_hash: int) -> str:
        if len(cid_bytes) < 8:
            return self.ring[four_tuple_hash % len(self.ring)]
        server_id = int.from_bytes(cid_bytes[1:4], 'big') & 0xFFFFF
        if server_id in self.active_workers:
            return self.active_workers[server_id]
        # Unknown/retired CID -> route consistently for Stateless Reset
        return self.ring[four_tuple_hash % len(self.ring)]
STAGE 03 · SAFE IMPLEMENTATION

CID Server-ID Decoder, 0-RTT Strike Gate & Graceful Drain

Validate CID >= 8BHeader Parseactive_workersLookupPrimary RouteFallback RingReset / InitialWorker IngressSafe Deliveryif unknown/init

1.Safe Bounds Check: Packets shorter than 8-byte CID fall back cleanly without out-of-bounds reads.

2.Two-Phase Drain: Remove draining workers from Initial-packet rotation first while honoring existing CIDs for 60s.

3.Stateless Reset: Unknown retired CIDs receive a cryptographic Stateless Reset token so clients reconnect fast.

Bounds-checked CID decoding and two-phase worker draining preserve live mobile sessions during deploys.

04
STAGE 04 · SCALING & KERNEL TUNINGintermediate

UDP GSO/GRO Batching, BBRv2 Pacing & Origin Connection Pooling.

Why this matters: Eliminate per-packet syscall bottlenecks and absorb bursty mobile reconnections without saturating origin pools.

Without kernel offload, 2M RPS of 1,200B packets triggers millions of sendmsg syscalls per second.

Enable UDP_SEGMENT (GSO) and UDP_GRO on worker sockets, pin one QUIC reactor thread per NIC RSS RX queue (SO_REUSEPORT + eBPF), and multiplex decoded HTTP/3 requests onto persistent HTTP/2/gRPC origin pools.

STAGE 04 · SCALING & KERNEL OFFLOAD

UDP GSO/GRO Batching, BBRv2 Pacing & Origin Connection Pooling

NIC RSS QueueZero Lock ContentionUDP_GRO / GSO2.5x CPU SavingsBBRv2 PacerLow BufferbloatOrigin H2/gRPC PoolBackend Efficiencypaces

1.RSS Core Pinning: Binding one QUIC event loop per NIC RX queue eliminates cross-core packet locks.

2.64 KB GSO Trains: Passing 50 segments in one sendmsg() closes the CPU gap with kernel TCP.

3.Backend Multiplexing: Edge workers terminate QUIC and reuse warm HTTP/2/gRPC pools to origin services.

NIC RSS core pinning, UDP GSO/GRO batching, and BBRv2 pacing keep edge CPU low and origin connections pooled.

05
STAGE 05 · FAULT ISOLATION & DDOSadvanced

3x Amplification Shield, RETRY Tokens & 0-RTT Strike Registers.

Why this matters: Defend UDP/443 ingress against reflection amplification, Initial floods, and 0-RTT replay attacks.

UDP port 443 is a prime target for spoofed-IP Initial floods and 0-RTT replay probes.

Under normal load, enforce RFC 9000's 3x unvalidated-byte limit. Under Initial flood (>20K Initials/sec/PoP), switch eBPF/worker ingress to stateless QUIC RETRY packets carrying an HMAC-signed address-validation token—costing zero server state.

STAGE 05 · FAULT ISOLATION & DDOS

3x Amplification Shield, RETRY Tokens & 0-RTT Strike Registers

Spoofed InitialFloodAttack TrafficStateless RETRY GateAddress Proof3x Byte CapReflection Shield2-Gen Strike FilterHTTP 425 Guardbounded by

1.Zero-RAM Flood Defense: Stateless RETRY challenges drop spoofed-source floods before allocating TLS or connection state.

2.Dual-Generation Bloom: Alternating 10-second Bloom filters prevent unbounded memory growth while catching all 0-RTT replays.

3.Strict Verb Allowlist: Block non-idempotent verbs in 0-RTT unconditionally at the gateway.

Stateless RETRY challenges, 3x amplification caps, and rotating 0-RTT strike filters absorb UDP floods with zero state exhaustion.

06
STAGE 06 · RECOVERY & DRAININGadvanced

Zero-Drop Worker Deploys via HTTP/3 GOAWAY & Stateless Resets.

Why this matters: Drain 500K-connection PoP workers cleanly during upgrades without breaking in-flight mobile requests.

Killing a QUIC worker pod abruptly drops 50K active mobile connections and forces slow timeout-based client retries.

On SIGTERM, the worker stops accepting new Initial CIDs, sends an HTTP/3 GOAWAY frame (last_stream_id) so clients open new streams on healthy pods, and finishes in-flight streams for up to 60 seconds.

STAGE 06 · RECOVERY & DRAINING

Zero-Drop Worker Deploys via HTTP/3 GOAWAY & Stateless Resets

SIGTERM DrainPhase 1 DrainHTTP/3 GOAWAYGraceful Handoff60s Drain ExpiryClean ExitStateless ResetTokenZero 30s Hangcompletes

1.Client-Visible Drain: HTTP/3 GOAWAY lets clients finish in-flight responses while routing new requests to fresh workers.

2.Shared Reset Secret: Derived HMAC reset tokens let any PoP node abort dead CIDs immediately without holding state.

3.Epoch Rotation: Bump the 4-bit CID epoch on deploy so eBPF never confuses old and new worker IDs.

HTTP/3 GOAWAY frames and HMAC-derived Stateless Reset tokens eliminate deploy-time connection stalls.

07
STAGE 07 · OBSERVABILITY & GUARDRAILSadvanced

Monitoring QLOG Loss, Anycast Flap Drops & Alt-Svc Circuit Breakers.

Why this matters: Detect ISP UDP throttling, CID misroutes, and 0-RTT replay spikes before mobile p99 degrades.

Encrypted QUIC traffic hides packet drops from traditional L4 switch counters.

Sample 1% QLOG traces per PoP, export quic_cid_misroute_total, quic_0rtt_425_total, quic_retry_triggered_total, and h3_to_h2_fallback_ratio per ASN.

STAGE 07 · OBSERVABILITY & GUARDRAILS

Monitoring QLOG Loss, Anycast Flap Drops & Alt-Svc Circuit Breakers

1% QLOG SamplingTransport HealthCID Misroute CounterRouting KPIASN Fallback RatioReachability KPIAlt-Svc SuppressionRegional Guardrailpairs with

1.Misroute Early Warning: Any spike in unknown-CID Stateless Resets points directly to an eBPF or BGP routing mismatch.

2.Per-ASN Alt-Svc Guard: Suppressing Alt-Svc headers for broken mobile carriers restores instant HTTP/2 loads.

3.Strike-Filter Saturation: Alert if 0-RTT 425 rejections spike, indicating clock skew or active replay probing.

QLOG sampling, CID misroute counters, and per-ASN Alt-Svc circuit breakers keep global HTTP/3 edge fleets reliable.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why does standard 4-tuple ECMP load balancing break active mobile QUIC connections when a user leaves Wi-Fi for 5G?

Recommended Learning Flow