Agent Wranglers

SCL-7Avoid

Pinning each visitor to one server

Do not route a visitor to the same server so that their state can live there.

How to do it

Sticky sessions break when that server stops, when a deploy restarts it or when autoscaling removes it. The visitor then loses their sign-in or cart. They also spread load unevenly, since a few heavy visitors stay on one server. The Twelve-Factor App says sticky sessions should never be used or relied upon. Keep the state in a shared store, as Keep no state inside the app process says.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/scaling/stateless-app-servers/no-sticky-sessions">Agent Wranglers scaling playbook</a>. In code you write, add a comment next to it with the same link.