Prompt
Do I need shared cache for a horizontally scaled app?
Latest observation
Oct 25, 2026
OpenAI APIWeb search: off
Not always.
For a horizontally scaled app, you only need a shared cache if the cached data must be consistent across instances or if any instance may need to read data cached by another instance.
Use a shared cache when:
- You need cache coherence across multiple app servers
- Cached data should survive requests hitting different instances
- You want to avoid duplicated cache entries on each node
- You store things like:
- session data
- rate limits
- auth/token lookup results
- expensive computed objects used by all nodes
Common choices: Redis, Memcached, or another distributed cache.
You may not need a shared cache when:
- The cache is purely local optimization on each server
- Data can be duplicated across instances
- Slightly stale or inconsistent cache is acceptable
- You use a load balancer with sticky sessions and the cache is session-local
- The cache is for very short-lived, node-specific data
Examples:
- per-instance in-memory cache for rendering templates
- local LRU cache for hot read-only config
- temporary request-level caching
Tradeoff
Shared cache gives consistency and easier coordination, but adds:
- network latency
- operational complexity
- a new dependency/failure point
Local cache is faster and simpler, but:
- data is duplicated
- invalidation is harder
- behavior varies by instance
Rule of thumb
- If the cached value must be seen by any instance, use a shared cache
- If it’s only an optimization and can differ between instances, local cache is fine
If you tell me what you’re caching, I can suggest whether shared cache is actually needed.