Skill 1.1.2

Describe differences between stateful and stateless concepts

Key Concepts

When application servers are stateless, any instance can handle any request, so a load balancer can spread traffic freely and Auto Scaling can add or remove instances without losing user data. Lambda functions should be treated as stateless too: an execution environment may be reused, but there is no guarantee, so nothing important should be kept only in memory or in /tmp.

State that must survive between requests, such as user sessions, shopping carts or workflow progress, should be moved to an external store such as Amazon ElastiCache, Amazon DynamoDB or Amazon S3. Sticky sessions on a load balancer can keep a user on one instance, but they make scaling uneven and lose the session if that instance fails, so an external session store is the preferred answer.