Interview Study Guide

Guide / System design Senior level

12. Senior-level questions — edge cases and lessons from production

Created · Updated · 5 min read

These are the questions that only feel obvious after you’ve been paged at 3 a.m. Each has a short model answer.

12.1 Data correctness#

  1. “Your cache and DB disagree for a product price at checkout. What do you do?” Price at checkout must come from the source of truth (or a versioned price snapshot stored with the cart); caches are for browsing. Show the user the final price before charging.
  2. “Two users buy the last item at the same instant.” Atomic conditional decrement (qty > 0) or reservation row with unique constraint; the loser gets “out of stock” or a backorder. Never check-then-update in app code.
  3. “An event was processed twice and a customer got two refunds.” Dedupe key on the refund (unique refund_request_id), ledger-level invariants (refunds ≤ captured amount), reconciliation alerts.
  4. “Events arrive out of order (“order shipped” before “order paid”).” Per-entity partition key for ordering, version numbers on events, state machine rejects invalid transitions or buffers until the predecessor arrives.
  5. “How do you backfill 2 billion rows without hurting production?” Batch by primary-key ranges, throttle by replica lag, run off-peak, make it idempotent and resumable with checkpoints, verify with counts/checksums.
  6. “How do you migrate from DB A to DB B with zero downtime?” Dual-write (or CDC from A to B) → backfill → shadow-read and compare → switch reads gradually → stop writes to A → decommission. Have a rollback at every step.
  7. “A soft delete exists but a GDPR deletion request arrives.” Hard-delete or crypto-shred (delete the per-user key), purge from caches, search indexes, backups policy, analytics copies, and logs.

12.2 Scale surprises#

  1. “Traffic is 100× for a 10-minute flash sale.” Pre-scale (autoscaling is too slow for spikes), virtual waiting room/queue, pre-warmed caches, inventory in Redis with atomic Lua, async order creation, degrade non-critical features, load-test beforehand.
  2. “One tenant is 40% of all traffic.” Dedicated shard/cell for that tenant, per-tenant rate limits and quotas, cell-based architecture to cap blast radius.
  3. “p50 is fine but p99 is 3 seconds.” Find tail causes: GC pauses, lock contention, a slow shard, cold cache, fan-out amplification (one request calling 50 services waits for the slowest). Fixes: hedged requests, timeouts, reducing fan-out, caching, isolating slow tenants.
  4. “The DB CPU is at 90% and you can’t shard this quarter.” Find the top queries (pg_stat_statements), add/fix indexes, cache hot reads, move reads to replicas, move analytics off the primary, batch writes, connection pooling, then scale up vertically as a bridge.
  5. “Kafka consumer lag keeps growing.” Add partitions + consumers (up to partition count), make processing faster (batching, async I/O), find a hot partition (skewed key), check slow downstream, scale the downstream or shed work.
  6. “Your Redis is using 95% memory.” Check big keys (--bigkeys), missing TTLs, eviction policy; compress values; move to a cluster; separate cache from queue workloads.

12.3 Reliability and operations#

  1. “Your service depends on 6 others, each 99.9% available. What’s your availability?” Roughly 0.999^6 ≈ 99.4% if all are on the critical path in series. Reduce by making dependencies async or optional, adding fallbacks and caching.
  2. “A retry storm took down your dependency during its recovery.” Retry budgets, jittered backoff, circuit breakers, server-side load shedding, and clients that respect Retry-After.
  3. “How do you deploy a breaking API change used by mobile apps you can’t force-upgrade?” Version the API, support old versions for months, add fields rather than change meaning, use feature flags, and track version usage to retire old ones.
  4. “Debug a request that is slow only for some users.” Distributed tracing by user/tenant, check which shard/region/cache node they hit, look at payload size or data skew (a user with 1M orders).
  5. “How do you know your backups work?” Scheduled automated restore tests and measured RTO; otherwise they don’t count.
  6. “What would you monitor on day one for this design?” The golden signals per service (latency, traffic, errors, saturation), business KPIs (orders/min, payment success rate), queue lag, replica lag, cache hit ratio, plus alerts tied to SLOs.

12.4 Architecture judgement#

  1. “Why not just use microservices from day one?” Network failures, distributed transactions, deployment and observability overhead; a modular monolith with clear module boundaries lets you split later along proven seams.
  2. “When is eventual consistency unacceptable?” Money movement, inventory allocation, authorization changes (revoking access), uniqueness (usernames). Elsewhere it’s usually fine, if the UI communicates it.
  3. “Would you build or buy (e.g. search, auth, queues)?” Buy/managed unless it’s your differentiator; factor cost at scale, lock-in, compliance, and team skill.
  4. “How would this design change at 10× and 100×?” Name the first bottleneck at each step (single DB primary → shard; single region → multi-region; synchronous calls → events). Staff-level answers show evolution, not one final diagram.
  5. “What’s the cost of this design?” Rough monthly estimate of the biggest line items (compute, storage, egress, managed services) and how you’d cut it (tiered storage, reserved capacity, caching, right-sizing).
  6. “What did you get wrong in a past design?” Have a real story: what broke, how you found it, what you changed. Interviewers value this more than a perfect diagram.

12.5 Subtle traps#

  • Auto-increment IDs leak business volume and enable enumeration (IDOR) — use opaque IDs externally.
  • COUNT(*) on a huge table is slow in Postgres (MVCC) — keep counters or use estimates.
  • Deleting a big range in Cassandra creates tombstones that slow reads — use TTL-based expiry and time-bucketed partitions.
  • Long transactions block vacuum in Postgres and bloat tables.
  • Webhooks you receive can be replayed by attackers — verify signatures and timestamps.
  • Time zones and DST break “daily” jobs — store UTC, schedule in the business’s zone explicitly.
  • “Exactly once” claims need a precise definition of where the guarantee ends.
Finished this page?Mark it done to track your progress across the guide.
Pritam Ghosh · System design & AI engineering study notes