Lambda on hard mode: Inside Modal's web infrastructure
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.
Related posts
- Modal's serverless Servers
Modal mediumAdept
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.
- 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.
- 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.
- Augment Your LiveKit Agent with Modal GPUs
Modal mediumAdept
LiveKit agents can offload custom or open-weights models to Modal serverless GPUs, demonstrated with a BitHuman Expression video avatar voiced by Qwen3-TTS. The BitHuman container's /launch endpoint returns as soon as the avatar joins the room, which conflicts with Modal Servers scaling on in-flight requests. Modal's Sticky Sessions solve this by letting the agent open a session before calling /launch and close it when the call ends, holding the container slot for the session's duration. GPU snapshots hide cold starts that would otherwise require reloading gigabytes of model weights.
- Modal is a computer
Modal easyNovice
Modal is best understood not as a neocloud or inference provider but as a computer: a virtual machine built across dozens of cloud providers, mapped component by component onto a classic computer architecture. Containers play the role of cores, the container runtime acts as the OS loader and scheduler, images are 'compiled' to filesystems with shared files deduplicated like shared libraries, and the storage hierarchy runs from container memory through page cache, ephemeral disk and Volumes to object storage. The Input/Output Plane, Routing Plane and Tunnels correspond to I/O, networking and RDMA-style bypass. The argument is that this extra virtualization layer aggregates and multiplexes demand for better resource efficiency than raw cloud primitives offer.