# distributed systems

// [39] real interview questions. Answers and sources live in the practice app.

practice this topic
  1. Compare weak, eventual, and strong consistency. When is each acceptable?(mid)
  2. Explain failover patterns: active-passive vs active-active. What are the drawbacks of failover?(mid)
  3. Compare master-slave and master-master database replication. What are the disadvantages of each?(mid)
  4. Synchronous vs asynchronous replication — what's the tradeoff and when do you pick each?(mid)
  5. What's the difference between federation and sharding for scaling a database?(mid)
  6. One shard of your database is receiving far more traffic than the others (hot partition). Diagnose and fix.(senior)
  7. SQL or NoSQL — how do you actually choose for a new service?(mid)
  8. Explain cache update strategies: cache-aside, write-through, write-behind, refresh-ahead. What goes wrong with each?(mid)
  9. What cache eviction policies do you know, and when would you use something other than LRU?(junior)
  10. Message queues vs task queues — what are they for, and when does adding a queue make a system worse?(mid)
  11. What is back pressure and how do you implement it in a service that's being overwhelmed?(senior)
  12. At-most-once vs at-least-once vs exactly-once message delivery — what do systems actually guarantee, and how do you get effectively-exactly-once?(senior)
  13. Layer 4 vs Layer 7 load balancing — what's the difference and when do you use each?(mid)
  14. What load balancing algorithms do you know, and how do you choose?(junior)
  15. Explain consistent hashing. What problem does it solve and why do we need virtual nodes?(senior)
  16. How does leader election work in a distributed system? What can go wrong?(senior)
  17. How would you implement a distributed lock? Discuss the Redis approach and its pitfalls.(senior)
  18. How do you handle a transaction that spans multiple services? Compare two-phase commit and sagas.(senior)
  19. What is event sourcing? What does it buy you and what does it cost?(senior)
  20. Explain CQRS. When is separating the read and write models worth it?(senior)
  21. Your service depends on two components, each with 99.9% availability. What availability can the service promise, and how do 'nines' work?(mid)
  22. Walk through what happens on a DNS lookup, and why is DNS-based load balancing/failover considered unreliable?(mid)
  23. Which latency numbers should every engineer know, and how do you use them in a back-of-envelope estimate?(mid)
  24. In a microservices architecture, how do services find each other? Explain service discovery.(mid)
  25. TCP vs UDP — differences, and when would you deliberately choose UDP?(junior)
  26. RPC vs REST for service-to-service communication — tradeoffs and when to pick each.(mid)
  27. Your order saga fails at the payment step after inventory was already reserved. Design the compensation flow, and compare choreography vs orchestration.(senior)
  28. The dual-write problem: your service must update its database AND publish an event. Why is 'commit, then publish' broken, and how does the transactional outbox fix it?(senior)
  29. Your Elasticsearch index and Redis cache keep drifting from the primary database. Compare dual writes vs change data capture (CDC) for keeping derived stores in sync.(senior)
  30. Your app must accept writes in three regions with sub-50ms local latency (active-active). Design the write path and the conflict story.(senior)
  31. Explain the circuit breaker pattern: the three states, and how it differs from timeouts and retries.(mid)
  32. Design health checks for a fleet behind a load balancer. Liveness vs readiness — and how can a bad health check take down the whole fleet?(mid)
  33. A dependency slows down and your retries turn the blip into a full outage (retry storm). Design a sane timeout and retry policy for a multi-layer call chain.(senior)
  34. What is a dead-letter queue, and how do you handle a poison message that keeps crashing your consumers?(mid)
  35. Long polling vs WebSockets vs Server-Sent Events — how do you choose a realtime transport?(mid)
  36. Define SLI, SLO, and SLA — and explain how an error budget changes the way a team ships.(senior)
  37. You message a friend whose phone is dead. Hours later they turn it on and every message you sent arrives at once, in order. How does a chat system deliver messages to a recipient who was completely offline?(mid)
  38. You send money and your bank app shows the payment 'done' with an updated balance in under a second — yet real interbank settlement takes hours or days. How does the app show it instantly without ever letting money be created or lost?(senior)
  39. You try to buy tickets the second they drop and the site puts you in a 'you are number 8,412 in line' waiting room instead of crashing. Design that virtual waiting room / queue in front of a sale.(senior)