System Design Interview Questions 2026: Scenario‑Based Prep for Distributed Caching and Rate Limiting
System design interviews in 2026 still hinge on distributed caching and rate limiting, but the scenarios have shifted toward latency‑aware caching, token‑bucket rate limiting at edge, and database sharding patterns that balance consistency and availability. Mastering these three areas—strategy, implementation, and scaling—gives you the confidence to tackle any scenario question with clarity and precision.
A few years ago, I sat with a junior dev who aced algorithm questions but froze when asked to design a URL shortener with sub‑100ms latency. We spent one evening mapping out a cache‑aside pattern with Redis, wiring a token‑bucket limiter at the API gateway, and partitioning the MySQL backend. The next week, he nailed a live interview and landed a role at a Series A startup. That moment stuck with me: system design isn’t theory—it’s a repeatable playbook you can learn.

What Distributed Caching Strategies Actually Work in Modern System Design?
Caching sits between your application and database to shave milliseconds off every request. The most common pattern is cache‑aside (also called lazy loading): the app checks the cache first, and if a miss occurs, it fetches from the database and populates the cache. This keeps logic simple and avoids stale data issues that write‑through can cause.

| Strategy | When to Use | Key Consideration |
|----------|-------------|-------------------|
| Cache‑aside | Read‑heavy, infrequent writes | Simple invalidation; app responsible for populating cache |
| Write‑through | Write‑heavy, need immediate consistency | Every write updates cache; slight write latency increase |
| Write‑behind | High‑throughput, eventual consistency acceptable | Batches writes to DB; risk of data loss if cache crashes |
| Local cache (e.g., Go cache2go, Node node-cache) | Ultra‑low latency for hot keys | Bypasses network round‑trip; must handle cache‑miss propagation |
A practical tip: always set a meaningful TTL and use versioned key prefixes (e.g., v1:user:123) so you can invalidate entire categories without scanning keys. Monitor hit‑ratio and latency; if hit‑ratio plateaus below 80 %, re‑evaluate your key distribution or TTL settings.
Code snippet (Python‑style cache‑aside with Redis):
import redis
import json
cache = redis.Redis(decode_responses=True)
def get_user(user_id):
key = f"v1:user:{user_id}"
data = cache.get(key)
if data:
return json.loads(data)
# fetch from DB (omitted for brevity)
# db_data = db.query(...)
cache.setex(key, 300, json.dumps(db_data)) # 5‑minute TTL
return db_data
How Should You Implement Rate Limiting at Scale?
Rate limiting protects your APIs from abuse and keeps latency predictable. The algorithm you choose depends on whether you need strict fairness, burst allowance, or simple per‑IP caps.
- Token bucket: allows configurable bursts while smoothing overall traffic. Ideal for per‑client limits where occasional spikes are acceptable.
- Leaky bucket: enforces a constant output rate; great for smoothing bursty traffic into steady streams.
- Sliding window counter: tracks requests in the last T seconds. More accurate than fixed‑window for avoiding thundering herd at second boundaries.
- Fixed window: simplest to implement but can allow burstiness at window edges.
In distributed systems, you need a shared state store. Redis Lua scripts are perfect for atomic increment‑and‑check operations, avoiding race conditions across multiple app instances.
Quick Go middleware example using Redis token bucket:
func RateLimit(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
key := r.Header.Get("X-Client-ID")
if key == "" {
key = r.RemoteAddr
}
lua := `
local key = KEYS[1]
local limit = tonumber(ARGV[1])
local window = tonumber(ARGV[2])
local now = tonumber(ARGV[3])
local tokens = redis.call("GET", key)
if tokens == false then
redis.call("SET", key, 0)
tokens = 0
end
if tokens < limit then
redis.call("INCRBY", key, 1)
return next.ServeHTTP(w, r)
end
`
now := float64(time.Now().Unix())
redis.Eval(lua, []string[key], 100, 60, now).Result()
http.Error(w, "rate limited", 429)
})
}
Choose limits based on your SLA: often 100‑500 requests/minute per user for public APIs, stricter for internal services. Pair rate limiting with retry‑after headers and graceful degradation (e.g., returning cached data instead of error 429).
What Database Scaling Patterns Handle Real‑World Traffic?
When a single database can’t keep up, you have three proven paths: sharding, read replicas, and CQRS. Each trades off consistency, complexity, and operational overhead.
- Sharding splits data across multiple DB instances based on a shard key (user ID, geography, tenant). Reduces load per instance but introduces cross‑shard query complexity. Use consistent hashing to minimize rebalancing pain.
- Read replicas offload read traffic toynchronously replicated from a primary. Ideal for read‑heavy workloads. Expect eventual consistency; route critical‑consistency reads to the primary.
- CQRS (Command‑Query Responsibility Segregation) separates write model from read model. Writes go to a write DB; reads query optimized materialized views or search indexes (Elasticsearch, OpenSearch). This pattern scales massively but doubles your data‑sync logic.
A practical middle ground many teams adopt: partitioned read replicas with selective primary queries. Route 90 % of reads to replicas and only hit the primary for financial transactions, password changes, or anything requiring immediate consistency.
Scenario quick‑fire list (10 common interview prompts):
- Design a distributed key‑value store with consistent hashing.
- Build a rate limiter for a URL‑shortening service handling 10 k QPS.
- Scale a read‑heavy social media feed using caching and replicas.
- Architect a cache invalidation strategy for a product‑catalog with frequent price updates.
- Implement per‑client rate limiting in a multi‑tenant SaaS platform.
- Design a sharding strategy for a global ride‑hailing app’s trip history.
- Choose between cache‑aside and write‑through for an e‑commerce checkout flow.
- Optimize database reads for a real‑time analytics dashboard.
- Handle cache stampede during a flash‑sale event.
- Balance consistency and latency in a global multi‑region deployment.
Let's Work Together
Looking to ace your next system design interview or build scalable architecture for your product? I’ve helped 168+ clients on Fiverr and bring 6+ years of full‑stack, AI automation, and DevOps experience to the table. Let’s connect and discuss how we can solve your toughest engineering challenges.




