A web application stores user sessions in server memory. Why is this a problem when scaling, and how do you fix it?
Short answer
In-memory sessions tie users to one instance (sticky sessions), lose sessions when an instance dies or scales in, and prevent even load balancing. Externalize session state to a shared store such as Redis, or use short-lived signed tokens, so any instance can serve any request.
Detailed answer
Problems: autoscaling removes instances and logs users out; deployments drop sessions; sticky sessions cause uneven load; failover loses state. Fixes: Spring Session with Redis, managed session stores, or token-based sessions (with server-side refresh token storage). Keep session data small.
What the interviewer expects
Understanding of stateless design as a prerequisite for horizontal scaling.
Common mistakes to avoid
Relying on sticky sessions as the long-term fix.