Migrated session storage to Redis for horizontal scaling. Forgot that Redis restarts log out every user.

The before:

  • Sessions stored in-memory on each server
  • Sticky sessions via load balancer
  • Works fine at small scale

The migration:

  • Centralized sessions in Redis
  • No more sticky sessions needed
  • Horizontal scaling possible

What we forgot:

  • Redis is in-memory by default
  • Restart = all sessions gone
  • 50,000 users logged out simultaneously
  • Support tickets: "Why did I get logged out?"

The fix:

  • Enable Redis persistence (RDB + AOF)
  • Redis Sentinel for high availability
  • Graceful degradation: fall back to JWT when Redis is down
  • Rolling restarts during maintenance windows

Lesson: In-memory storage is ephemeral. If losing the data causes user impact, you need persistence and redundancy.


← Назад към Научени Уроци