Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Modal 5 min read Announcement mediumAdept

Serverless routing made sticky

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.

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.

  • 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.

  • 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.

  • 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 functions vs containers: CI/CD, database connections, cron jobs, and long-running tasks

    Railway mediumAdept

    Serverless functions and container platforms differ in execution model, which changes how you handle deploys, database access, cron jobs, rollbacks and long-running work. Serverless imposes execution limits of 30 seconds to 15 minutes, memory caps, cold starts and no persistent connections, so long jobs need checkpointing, chained invocations or streaming. Railway's containers avoid those limits and add automatic private networking, reference variables for credentials, and cron with skip-if-running semantics that requires jobs to close connections and exit. Rollbacks are similar on both, but schema migrations should stay backward compatible because rolling back code does not reverse them.

The quest for software engineering knowledge.

Look:
Layout: