**When building scalable backend systems, one common question arises:
“If we scale our application using multiple instances, how should caching work?”
This becomes especially important when using Redis in distributed architectures.
Let’s understand the problem step by step and then move toward advanced scaling concepts like sharding and replication .**
🚨 The Problem with Local Redis per Instance
Suppose we scale our backend application:
Load Balancer ↓ ┌───────────┐ │ Instance1 │ └───────────┘ │ Local Redis 1
┌───────────┐ │ Instance2 │ └───────────┘ │ Local Redis 2
Enter fullscreen mode
Exit fullscreen mode
At first glance, this looks fine.
But here’s the issue.
Imagine:
User data gets updated through Instance 2
Local Redis 2 gets updated
Local Redis 1 still contains old cached data
Now:
Requests routed to Instance 1 return stale data
Requests routed to Instance 2 return fresh data
This creates:
Cache inconsistency
Synchronization complexity
Stale reads
❌ Why Syncing Local Redis is…