Interview Practice Problems
Staff+ distributed systems interviews are among the most challenging in the industry. This module provides comprehensive practice problems with detailed solutions, covering the exact topics asked at Google, Meta, Amazon, and other top companies. Think of these problems the way a pilot thinks about flight simulators: the scenarios are designed to trigger the exact failure modes and trade-off decisions you will face in a real interview. Working through them builds the muscle memory so that under pressure, the right architectural instincts surface automatically.Problem Count: 15+ detailed problems
Difficulty: Staff/Principal level
Format: Problem → Hints → Full Solution → Follow-up Questions
Difficulty: Staff/Principal level
Format: Problem → Hints → Full Solution → Follow-up Questions
Problem 1: Design a Distributed Rate Limiter
Problem Statement
Design a rate limiting system that:- Limits requests per user to 100 requests per minute
- Works across multiple API servers (horizontally scaled)
- Has low latency (< 5ms overhead)
- Handles millions of users
Hints
Hint 1: Algorithm Choice
Hint 1: Algorithm Choice
Consider Token Bucket, Leaky Bucket, Sliding Window, or Fixed Window algorithms.
- Token Bucket: Good for burst tolerance
- Sliding Window: More accurate, more complex
- Fixed Window: Simple but has edge case issues
Hint 2: Storage
Hint 2: Storage
Where do you store rate limit state?
- Local memory: Fast but not shared
- Redis: Shared but adds latency
- Hybrid: Local + periodic sync
Hint 3: Race Conditions
Hint 3: Race Conditions
Multiple servers checking/updating same counter simultaneously.
Consider atomic operations or Lua scripts in Redis.
Solution
-
How do you handle Redis failures?
- Fail open (allow requests) or fail closed (deny)?
- Local cache with eventual sync?
-
How do you prevent gaming the system?
- User changes IP? Use account ID, not IP
- Distributed attacks? Per-IP limits too
-
How do you handle different rate limits per user tier?
- Store tier in user metadata
- Different limits for free vs paid
Problem 2: Design a Distributed Lock Service
Problem Statement
Design a distributed lock service similar to Zookeeper or etcd that:- Provides mutual exclusion
- Handles node failures
- Prevents deadlocks
- Supports lock TTL (lease-based)
Solution
-
What happens during network partition?
- Clients on minority side can’t acquire new locks
- Existing leases expire, preventing split-brain
-
How do you handle leader election for the lock service itself?
- Raft consensus with quorum reads/writes
-
Redlock controversy: Why is Redis Redlock problematic?
- Martin Kleppmann’s analysis: Clock assumptions too strong — Redlock assumes bounded clock drift across independent Redis nodes, but NTP jumps and VM clock corrections can violate this
- Antirez’s rebuttal: argues real-world clocks are “good enough” with proper monitoring
- The bottom line: If you need the lock for correctness (not just performance), fencing tokens are non-negotiable regardless of the locking mechanism. If you need the lock only for efficiency (avoiding duplicate work), Redlock is acceptable
Problem 3: Design a Global Payment System
Problem Statement
Design a payment processing system that:- Handles credit card charges globally
- Guarantees exactly-once processing
- Supports refunds and chargebacks
- Processes millions of transactions per day
Solution
Problem 4: Design a Distributed Task Scheduler
Problem Statement
Design a system that:- Schedules tasks to run at specific times (cron-like)
- Executes one-time delayed tasks
- Guarantees at-least-once execution
- Scales horizontally
Solution
Problem 5: Design a Distributed Unique ID Generator
Problem Statement
Design a system that generates globally unique IDs with:- 64-bit IDs
- Sortable by time (roughly)
- No coordination between nodes
- Millions of IDs per second
Solution
-
How do you assign node IDs?
- Zookeeper/etcd for coordination
- Use MAC address hash
- Use Kubernetes pod ordinal
-
What if clock goes backwards?
- Throw exception (let operator fix NTP)
- Wait for clock to catch up
- Use logical clock component
-
How do you handle datacenter failover?
- Split node ID: 5 bits datacenter + 5 bits machine
- Different epoch per datacenter
Problem 6: Design a Distributed Message Queue
Problem Statement
Design a message queue like Kafka that:- Handles millions of messages per second
- Provides ordering guarantees (per partition)
- Supports multiple consumers
- Persists messages for replay
Key Design Points
More Practice Problems
Design Uber/Lyft
Topics: Real-time location, matching, surge pricing
Key challenges: Geospatial indexing, low-latency dispatch
Design Twitter Timeline
Topics: Fan-out, feed ranking, real-time updates
Key challenges: Hot users, read-heavy workload
Design Google Docs
Topics: CRDT, operational transformation, collaboration
Key challenges: Conflict resolution, real-time sync
Design Netflix
Topics: CDN, video encoding, recommendations
Key challenges: Global scale, adaptive streaming
Interview Tips
How to Structure Your Answer
How to Structure Your Answer
-
Clarify requirements (5 min)
- Scale: Users, requests/second, data size
- Consistency: Strong or eventual?
- Latency: What’s acceptable?
-
High-level design (10 min)
- Draw boxes and arrows
- Identify core components
- Explain data flow
-
Deep dive (20 min)
- Pick 2-3 most critical components
- Discuss algorithms, data structures
- Explain trade-offs
-
Handle edge cases (10 min)
- Failures: Node crashes, network partitions
- Scale: Hot spots, bottlenecks
- Consistency: Race conditions
What Interviewers Look For
What Interviewers Look For
- Breadth: Can you identify all components?
- Depth: Can you go deep on key areas?
- Trade-offs: Do you understand CAP, consistency vs availability?
- Practicality: Is your design buildable?
- Communication: Can you explain clearly?
Common Mistakes to Avoid
Common Mistakes to Avoid
- Starting to code before understanding the problem — spend at least 3-5 minutes on requirements
- Not asking clarifying questions — interviewers deliberately leave gaps to see if you probe
- Ignoring scale constraints — “works for 100 users” and “works for 100 million users” are fundamentally different systems
- Over-engineering simple problems — if the interviewer says “single region, moderate scale,” do not design a globally distributed system
- Forgetting failure modes — always ask yourself: “What happens when this component goes down?”
- Not discussing trade-offs — saying “I would use Kafka” without explaining why (vs. SQS, RabbitMQ, etc.) signals shallow understanding
- Treating consistency as binary — many candidates say “eventually consistent” without specifying what guarantees their users actually need (read-your-writes, monotonic reads, etc.)