Modal's serverless Servers
Modal Servers are a low-latency HTTP/WebSocket/gRPC serving primitive that cut p50 request latency from 39ms to 6ms versus Modal Web Functions by dropping platform-managed queueing and keeping network calls off the hot path. Requests flow through an AWS NLB, an Envoy edge proxy that terminates TLS and normalizes traffic to multiplexed HTTP/2, and fprs, a stateless Rust proxy built on Cloudflare's pingora. fprs maps domains to replicas using an in-memory cache reconciled from Spanner change streams, and it also handles autoscaling signals, proxy-level auth and traffic mirroring. The tradeoff is UDP-like: with no replica available, clients get a 503, and queueing and load shedding are pushed to the application in exchange for minimal routing overhead.
Related posts
- Lambda on hard mode: Inside Modal's web infrastructure
Modal mediumAdept
Modal's modal-http service, written in Rust on hyper and Tokio, serves HTTP and WebSocket traffic for serverless functions by translating each request into a function call instead of reverse-proxying to containers. Requests are represented as ASGI events serialized as Protocol Buffers and streamed over low-latency message queues, with batching (1 MiB or 2 ms chunks) and backpressure propagated through TCP or HTTP/2 flow control. This design lets function calls share the same scheduling infrastructure and supports request bodies up to 4 GiB and unlimited streaming responses, far beyond limits such as AWS Lambda's 6 MB. It also suits long-running, compute-heavy containers that can use up to 64 CPUs and 8 H100 GPUs.
- Serverless routing made sticky
Modal mediumAdept
Modal's Sticky Sessions pin every request in a session to the same serverless container, which suits stateful workloads like streaming speech-to-text, voice agents, shared rooms and multiplayer games without resorting to max_containers=1. The feature builds on Modal Servers and their stateless proxy (fprs). Routing metadata is encoded in a signed session token, so the proxy holds no session-to-container mapping. Load balancers combine periodic concurrency probes with recent routing decisions to place sessions, and the autoscaler treats sessions rather than requests as the unit of concurrency, queuing new sessions when capacity runs out.
- Bringing serverless functions closer to the speed of wire
Modal mediumAdept
Modal rebuilt its serverless I/O plane, which queues Function inputs and outputs, and now runs it in at least four regions. A new `routing_region` flag lets callers avoid round trips to us-east, and the completed migration cut end-to-end Function Call latency by about 80ms at p50. The redesign moves non-critical work like autoscaling stats and dashboard events to the background and minimizes shared-storage access on the hot path, using client-side metadata caching and JWT-based auth. It also rewrites the server layer from async Python to Go to avoid event-loop lag, and stays on Redis 7.1 for its Redis-streams queues after load tests showed CPU spikes from 7.2 onward. Users are advised to route near their clients, keep payloads under 2MiB to skip blob-storage uploads, and batch small inputs.
- WireGuard at Modal: Static IPs for serverless containers
Modal hardMaster
Modal built vprox, a high-availability Go VPN proxy on WireGuard, to give multi-tenant serverless containers static outbound IPv4 addresses for things like database IP allowlists. An earlier SOCKS5 approach broke with libraries that don't use the standard socket module, so Modal moved to Layer 3: clients get WireGuard keys and IPs over an HTTPS connect endpoint, idle peers are reaped by last-handshake time, and clients re-register when ping probes fail. Per-container traffic is steered through Linux policy-based routing with a dedicated routing table per container, because an eBPF xdp_redirect approach bypassed netfilter and broke SNAT. Each proxy node hosts many IPs (up to 240 on an AWS c7gn.8xlarge, under $0.01/hr per IP). A reconciliation loop watches cloud instance metadata so IPs can be moved between nodes for failover within seconds.
- Endpoint Candidates: evaluate and promote inference endpoints
Modal mediumAdept
Endpoint Candidates let Modal users stage alternative deployments of a Dedicated Endpoint, such as new checkpoints or different models, mirror a sample of production traffic to them, measure latency, throughput, cost and quality, then promote a winner from the dashboard to the existing URL. Under the hood, Modal's Pingora-based proxy forks each request stream into a bounded per-Candidate buffer and also caps shared mirrored body memory per proxy process. A chunk is counted until its last network write releases it. When either limit is hit, the mirrored request is cancelled so production is never slowed. Mirroring is best-effort by design, and Candidates bill at standard compute pricing.