Second-order effects
Good designers ask “what happens under load, during failure, at the edges?”. Caches go stale, keys get hot, retries amplify outages and replicas lag — know the symptoms and the fixes.
- CachingStaleness and stampedes.
- DataHot partitions and replication lag.
- ReliabilityRetries, exactly-once and microservice latency.
Senior design interviews include “gotcha” follow-ups: what breaks under load, what your cache really guarantees, why retries can make outages worse. These questions train you to see second-order effects — the mark of an experienced engineer.
1. You added a cache and users see stale prices. What happened and how do you fix it?
The cache is serving data after the database changed — no invalidation, or a long TTL. Fix by invalidating (or updating) the cache key on every write, using shorter TTLs for volatile data, and never caching values that must be exact (checkout prices are read from the database). Decide per data type how stale is acceptable.
2. A celebrity posts and one database shard melts. Why?
A hot key/partition: all reads and writes for that user hit one shard. Mitigate with caching the hot item, read replicas, splitting the key (adding a suffix to spread counters), and special handling for celebrity accounts (fan-out on read).
3. What is a thundering herd (cache stampede)?
A popular cache entry expires and thousands of requests miss at once, all hitting the database. Fixes: request coalescing (one request recomputes, others wait), probabilistic early refresh, staggered TTLs with jitter, and serving stale data while refreshing.
4. Can a message queue give you exactly-once processing?
Not end to end on its own. Brokers offer at-least-once delivery (and some offer exactly-once within their own transactions), but crashes between processing and acknowledgement cause redelivery. Real systems achieve “effectively once” with idempotent consumers and de-duplication keys.
5. How can retries turn a small problem into a full outage?
If a slow service makes every client retry immediately, load multiplies (a retry storm) and the service never recovers. Use exponential back-off with jitter, retry budgets, circuit breakers and timeouts shorter than the caller's own timeout.
6. Your read replica shows a user their old profile right after they edit it. Why?
Replication lag: the write went to the primary, the read hit a replica that has not caught up. Provide read-your-writes consistency — route that user's reads to the primary for a short time, or use session tokens with replication positions.
7. Is adding more servers always the fix for slowness?
No. If the bottleneck is the database, a lock, a single-threaded component or a slow downstream API, more app servers only add pressure. Measure first (latency breakdowns, saturation metrics), then scale the actual bottleneck or remove the work.
8. Microservices made the system slower. Why can that happen?
Every in-process call became a network call with serialisation, latency and failure modes; chatty synchronous chains add up (five services × 50 ms = 250 ms). Reduce chattiness with coarse-grained APIs, asynchronous events, caching and merging services that always change together.
Remember
Key points
- Invalidate on write
Or accept and document staleness.
- Jitter everything
TTLs and retries.
- Idempotent consumers
The real “exactly once”.
- Measure the bottleneck
Before adding servers.
Interview drill
Follow-up questions
What the interviewer asks after your first answer. Turn on practice mode, answer each one aloud, then reveal.
-
1 Write-through vs write-behind caching risks? Intermediate
Write-through adds write latency but stays consistent; write-behind is fast but can lose data if the cache fails before flushing.
-
2 Why can a single global counter become a bottleneck? Intermediate
Every increment contends on one row or key; shard the counter into several and sum them when reading.
-
3 Why is distributed tracing important after splitting into services? Basic
It shows where time is spent across services for one request, revealing slow hops and failures.
-
4 Strong consistency for likes count — worth it? Basic
Usually not; eventual consistency is fine and far cheaper at scale.
-
5 What is a poison message? Intermediate
A message that always fails processing and blocks a queue if retried forever; move it to a dead-letter queue after a few attempts.
-
6 How do you deploy a database schema change with zero downtime? Advanced
Expand and contract: add new columns or tables compatible with old code, deploy code that writes both, backfill, switch reads, then remove the old structure later.