advancedScenario Questions

Scenario 27: After scaling from one server instance to three behind a load balancer, users report being logged out mid-session at random.

With traditional stateful (session-cookie) authentication and no sticky sessions or shared session store, a user's in-memory session on instance A isn't visible if the load balancer routes their next request to instance B. Fix with either load-balancer sticky sessions or, more robustly, externalizing sessions with Spring Session backed by Redis so any instance can serve any authenticated request.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Scenario 28: Your application needs to authenticate a WebSocket connection used for real-time account balance updates.← Back to all Spring Security questions