Skip to the guide

Stateless services and sessions

BeginnerConcept3 pages

A stateless service keeps nothing between requests that it would miss if it vanished. That's what lets the load balancer send any request to any copy, and lets autoscaling and deploys add and remove copies freely. The state still exists. It just lives in places built to keep it: a database, a shared cache, object storage, or the client itself. The question interviewers press on is where the logged-in session goes.

Loyalty stamps at a coffee chain

A coffee chain gives you a stamp for every coffee, and the tenth is free. There are three ways to keep count. One barista can remember you in her head: lovely, until she's off sick, or you're served by her colleague, who has never seen you. The shop can keep a book behind the counter, listed by your card number, which every barista reads. Or you can carry a stamped card that any branch accepts, with stamps that are hard to fake. No book to check, but if your card is stolen, the shop can't cancel it.