« All posts

Edge Gateway Architecture: Diskless Design and the Rust DashMap Trap

A deep dive into Cloudflare-style edge gateway architecture: data/control plane separation, in-memory TLS, WASM sandboxing, and the Rust DashMap deadlock pitfall.

This architectural piece examines how modern edge gateways, similar to Cloudflare and Fastly, are engineered for extreme throughput. The central philosophy is strict separation between data plane and control plane: edge nodes perform O(1) in-memory operations with zero disk I/O, while persistence and complex business logic are pushed to a central management engine. The pipeline flows through TLS termination, DashMap-based risk/billing gatekeeping, Wasmtime sandbox execution, lock-free logging, and response output.

Four core engineering solutions are detailed: atomic billing counters stored in shared memory (mmap) for near-instant crash recovery; lazy-loaded TLS certificates combined with keyless SSL to serve millions of certs without local storage; AOT-precompiled sandbox execution enabling sub-millisecond tenant code startup; and lock-free ring-buffer logging streamed directly to Kafka or ClickHouse without touching disk.

The article also flags two high-risk boundaries: cold domain flood attacks that can overwhelm central KV lookups, mitigated via negative caching and distributed Bloom filters, and the notorious Rust DashMap deadlock trap, where holding a read guard while attempting a write on the same shard causes a lock conflict — solved through disciplined scoping and explicit drop() calls. The overarching takeaway is that data consistency should be 'as weak as business constraints allow,' since an edge gateway's sole mission is maximum-speed traffic forwarding, not acting as a storage engine.