What is the main scaling tradeoff introduced by stateful MCP sessions?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A stateful MCP session pins a client to one server instance, so the load balancer needs sticky routing, which blocks the stateless horizontal scaling that cloud replicas rely on.
Think of a coat check at a theater. The first time you arrive, you hand over your coat and get a numbered ticket; the attendant remembers which hook holds your coat for the whole evening. That memory is convenient: you do not re-describe your coat every time. But it means you must return to that exact attendant. If the theater hires ten attendants and sends you to a random one, only the one holding your ticket can find your coat. A stateful MCP session works the same way. The server remembers your session in its own memory after one setup handshake, so later messages get there fast. The cost is that every later message has to come back to that same server; you cannot just spray requests across a fresh pool of identical servers.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: session lifecycle and capability negotiation, what the persistent channel buys, why in-memory state forces sticky routing, the conflict with stateless scaling, and the stateless-mode or shared-store mitigations.
| Concern | Stateful MCP session | Stateless request-response |
|---|---|---|
| Capability negotiation | Once at initialize, reused | Implied or repeated per call |
| Notifications, subscriptions | Yes, pushed over live channel | No, client must poll |
| Routing requirement | Sticky, affinity to one instance | Any replica, fully interchangeable |
| Horizontal scaling | Constrained, pinned traffic | Native, spread freely |
| Failure on instance loss | Session dies, must reconnect | Retry hits any healthy replica |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Picking TLS or disk serialization. The real cost is sticky routing: session state lives in one instance's memory, so the load balancer must pin the client there.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.