ModalSiwon Park, Kartik Sinha, Kathir Meyyappan, Daniel ShaarAnnouncement
Serverless routing made sticky
Summary
Modal launched Sticky Sessions, a serverless routing feature that guarantees all requests in a session reach the same container, solving the problem of stateful workloads that require continuity between requests. Use cases include speech-to-text models with decoder state, voice agents holding conversations, and multiplayer games where players must reconnect to the same container. Sticky Sessions build on Modal’s in-house stateless proxy (fprs) and use a signed session token returned by sessions.start() to encode routing metadata, avoiding the need for proxy state and enabling fixed routing without persistent mapping. Load balancing probes containers for concurrency snapshots and combines them with recent routing decisions to distribute sessions evenly, while autoscaling monitors active session counts and queued demand to size the compute fleet appropriately. The feature enables low-latency voice agents via WebRTC signaling, shared chat rooms where clients share a session token, and gaming applications that preserve in-memory state across player reconnections.
Context
Stateful serverless workloads such as speech-to-text models, voice agents, and multiplayer games require requests to land on the same container for session continuity, which Modal’s existing request-level routing did not guarantee.
Approach / What changed
Modal implemented Sticky Sessions using a signed session token returned by sessions.start() to encode routing metadata, load balancers that probe containers for concurrency snapshots and combine them with recent routing decisions, and an autoscaler that monitors active session counts and queued demand to size the compute fleet.
Takeaways
Sticky Sessions use a signed session token returned by sessions.start() to encode routing metadata, avoiding the need for proxy state and enabling fixed routing without persistent mapping.
Load balancing probes containers for concurrency snapshots and combines them with recent routing decisions to distribute sessions evenly across available containers.
Autoscaling uses active session counts and queued demand as the unit of concurrency, rather than request volume, to size the compute fleet.
FAQ
How does Sticky Sessions handle authorization without a Proxy Token?
Each sessions.start() request returns a signed session token that grants access to that session. Sharing this token among clients allows multiple participants to access the same state without turning off authentication or passing the Proxy Token around.
How does load balancing work without proxy session state?
Load balancers periodically probe containers for a snapshot of their available concurrency. They combine recent routing decisions with probed snapshots to inform container selection, evenly distributing sessions while minimizing wasted roundtrips to containers that are out of capacity.
What workloads does Sticky Sessions enable?
Sticky Sessions enable low-latency voice agents (e.g., Pipecat agent over WebRTC), shared rooms (e.g., chat room where each room is a session), and gaming applications (e.g., Curvytron multiplayer game) that require session continuity and in-memory state.
Source and freshness
- Source
- modal.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.