Course contentsShow
← System Design
Lesson 59 of 1,9192. Scaling FoundationsFree lesson

Externalizing State with Shared Storage

Moving session state out of application servers into Redis, databases, or distributed caches.

Externalizing State with Shared Storage

What You'll Learn

You'll learn how to remove session state from your application servers by storing it in shared external systems like Redis or databases.

The Core Problem

Remember that stateful services are hard to scale horizontally because each server holds unique data (like user sessions). When you externalize state, you move that data out of your application servers into a separate storage layer that all servers can access.

How It Works

Instead of keeping session information in server memory, you store it in a shared location:

  • Redis/Memcached: Fast, in-memory key-value stores perfect for session data
  • Databases: Traditional storage for persistent user state
  • Distributed caches: Systems designed for shared access across many servers

Now when a request arrives at any application server, that server fetches the session data from the shared storage, processes the request, and updates the storage if needed. Your application servers become stateless—they're just processing machines that temporarily borrow state from elsewhere.

The Analogy

Think of coat check at a restaurant. Instead of each waiter remembering which coat belongs to which customer (stateful waiters), customers receive tickets and coats are stored in a central closet. Any waiter can retrieve any coat using the ticket number. The waiters are now stateless; the closet is the shared storage.

Trade-offs

You gain horizontal scalability (add more servers anytime) and eliminate single points of failure (any server can handle any request). However, you now depend on the external storage system, and every request requires a network call to fetch state—adding latency.

Key Takeaway: Externalizing state transforms stateful servers into stateless ones by moving session data into shared storage systems like Redis, enabling seamless horizontal scaling at the cost of network latency and storage system dependency.