# distributed systems
// [39] real interview questions. Answers and sources live in the practice app.
practice this topic- Compare weak, eventual, and strong consistency. When is each acceptable?(mid)
- Explain failover patterns: active-passive vs active-active. What are the drawbacks of failover?(mid)
- Compare master-slave and master-master database replication. What are the disadvantages of each?(mid)
- Synchronous vs asynchronous replication — what's the tradeoff and when do you pick each?(mid)
- What's the difference between federation and sharding for scaling a database?(mid)
- One shard of your database is receiving far more traffic than the others (hot partition). Diagnose and fix.(senior)
- SQL or NoSQL — how do you actually choose for a new service?(mid)
- Explain cache update strategies: cache-aside, write-through, write-behind, refresh-ahead. What goes wrong with each?(mid)
- What cache eviction policies do you know, and when would you use something other than LRU?(junior)
- Message queues vs task queues — what are they for, and when does adding a queue make a system worse?(mid)
- What is back pressure and how do you implement it in a service that's being overwhelmed?(senior)
- 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)
- Layer 4 vs Layer 7 load balancing — what's the difference and when do you use each?(mid)
- What load balancing algorithms do you know, and how do you choose?(junior)
- Explain consistent hashing. What problem does it solve and why do we need virtual nodes?(senior)
- How does leader election work in a distributed system? What can go wrong?(senior)
- How would you implement a distributed lock? Discuss the Redis approach and its pitfalls.(senior)
- How do you handle a transaction that spans multiple services? Compare two-phase commit and sagas.(senior)
- What is event sourcing? What does it buy you and what does it cost?(senior)
- Explain CQRS. When is separating the read and write models worth it?(senior)
- Your service depends on two components, each with 99.9% availability. What availability can the service promise, and how do 'nines' work?(mid)
- Walk through what happens on a DNS lookup, and why is DNS-based load balancing/failover considered unreliable?(mid)
- Which latency numbers should every engineer know, and how do you use them in a back-of-envelope estimate?(mid)
- In a microservices architecture, how do services find each other? Explain service discovery.(mid)
- TCP vs UDP — differences, and when would you deliberately choose UDP?(junior)
- RPC vs REST for service-to-service communication — tradeoffs and when to pick each.(mid)
- Your order saga fails at the payment step after inventory was already reserved. Design the compensation flow, and compare choreography vs orchestration.(senior)
- 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)
- 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)
- Your app must accept writes in three regions with sub-50ms local latency (active-active). Design the write path and the conflict story.(senior)
- Explain the circuit breaker pattern: the three states, and how it differs from timeouts and retries.(mid)
- 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)
- 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)
- What is a dead-letter queue, and how do you handle a poison message that keeps crashing your consumers?(mid)
- Long polling vs WebSockets vs Server-Sent Events — how do you choose a realtime transport?(mid)
- Define SLI, SLO, and SLA — and explain how an error budget changes the way a team ships.(senior)
- 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)
- 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)
- 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)