Back to Architecture Library
Compute & Scaling
Session Management
How to track users across multiple requests in a distributed system.
Misconceptions
- •Sticky sessions are the best way to handle sessions (they can lead to unbalanced load)
- •Local server memory is fine for session storage
Trade-offs
- •User Experience vs. System Balance
- •Centralized Store Latency vs. Local Speed
The Mental Model
In a scaled environment, users may hit different servers. Session management involves using external stores (like Redis) or "sticky sessions" to ensure the user's data is accessible regardless of which instance they hit.
Interactive Simulation
Node A
Node B
Local storage makes the node stateful. If the user hits Node B, they'll be logged out.
Architecture Primitives v1.0
Architect's Tip
When scaling for session management, always consider the impact on downstream dependencies like databases and message queues.