BolEnglishLearn · Play · Win
Login

🪶 System Design · System Building Blocks

🪶

Stateless Design

Building BlockIntermediateModule 3

A server does not depend on local memory from a previous request.

Stateless services are easier to distribute across multiple servers.

💡 In practice

Any server can process the next API request because session state is stored appropriately.

🖼️ CONCEPT PICTURE
A picture to help remember Stateless Design
Any server can process the next API request because session state is stored appropriately.

💡 Like a hotel where any front-desk clerk can help you, because your booking is in the system, not in one clerk's head.

💡 Learn🛠️ Apply🎯 Check

💡 Why it matters

If a server remembers a user only in its own memory, that user breaks the moment a load balancer sends them elsewhere. Stateless servers are interchangeable, so you can add, remove or restart them freely. This is what makes scaling out and recovering from failures smooth instead of painful.

🛠️ How to achieve it

1
Keep state outside the server
Store session and shared data in a database or cache that all servers can reach.
2
Carry what each request needs
Let each request include or look up the information it needs, rather than relying on server memory.
3
Make servers disposable
Design so any server can be replaced or restarted without losing user progress.
4
Avoid sticky memory
Do not store per-user data in a single server's memory between requests.

⚠️ Signs of trouble

  • •A user breaks when sent to a different server.
  • •Restarting a server logs everyone out.
  • •Sessions are kept only in one server's memory.
  • •You cannot add servers without special sticky routing.
⚠️ Common mistake: Keeping session data in a single server's memory, which breaks as soon as traffic is spread. Store shared state in a database or cache that every server can reach.

🎯 Quick check

Score: 0/3

Three questions to test the idea.

  1. 1. What makes a server stateless?

    Answer: It keeps no per-user memory between requests

    A stateless server relies on shared storage, so it remembers nothing private between requests.

  2. 2. Why does stateless design help scaling?

    Answer: Any server can handle any request, so you can add or remove servers freely

    Interchangeable servers let a load balancer spread traffic and let you scale out smoothly.

  3. 3. Where should session state live in a stateless design?

    Answer: In a shared store like a database or cache

    Shared storage lets every server read the same session, so no user is tied to one machine.

🔑 Key terms

State
Information remembered between requests, like a session.
Stateless
A server that keeps no per-user memory between requests.
Session store
A shared place that holds user session data.
Sticky session
Pinning a user to one server, which limits scaling.

✅ Review checklist

📊 Your progress

0%
Mark this topic learned to track it.
Saved in this browser.
🚀 Got it?
Mark it learned and move to the next topic.
Next topic →