Skip to main content

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

Problem 1: Design a Distributed Rate Limiter

Difficulty: Medium-Hard
Companies: Stripe, Cloudflare, AWS
Time: 45 minutes

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

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
Where do you store rate limit state?
  • Local memory: Fast but not shared
  • Redis: Shared but adds latency
  • Hybrid: Local + periodic sync
Multiple servers checking/updating same counter simultaneously. Consider atomic operations or Lua scripts in Redis.

Solution

Redis Lua Script (Atomic Operation):
Distributed pitfall: Clock skew between your API servers means the now timestamp passed to this script may differ by milliseconds across servers. For a 60-second window this is negligible, but for sub-second windows (e.g., 10 requests per 100ms), use Redis server time via redis.call('TIME') instead of client-supplied timestamps.
Follow-up Questions:
  1. How do you handle Redis failures?
    • Fail open (allow requests) or fail closed (deny)?
    • Local cache with eventual sync?
  2. How do you prevent gaming the system?
    • User changes IP? Use account ID, not IP
    • Distributed attacks? Per-IP limits too
  3. 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

Difficulty: Hard
Companies: Google, Amazon, Uber
Time: 45 minutes

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

Lock Acquisition Algorithm:
Follow-up Questions:
  1. What happens during network partition?
    • Clients on minority side can’t acquire new locks
    • Existing leases expire, preventing split-brain
  2. How do you handle leader election for the lock service itself?
    • Raft consensus with quorum reads/writes
  3. 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

Difficulty: Very Hard
Companies: Stripe, Square, Adyen
Time: 60 minutes

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

Exactly-Once Processing: Think of this like a post office with registered mail: each letter (payment) gets a unique tracking number (idempotency key). If the sender asks “did my letter arrive?”, the post office can check the tracking number and say “yes, here’s the confirmation” — without delivering the letter a second time.
Key Design Decisions:

Problem 4: Design a Distributed Task Scheduler

Difficulty: Hard
Companies: Uber (Cadence), Airbnb, LinkedIn
Time: 45 minutes

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

Handling Exactly-Once Semantics:

Problem 5: Design a Distributed Unique ID Generator

Difficulty: Medium
Companies: Twitter (Snowflake), Instagram
Time: 30 minutes

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

Implementation: The elegance of Snowflake is that each node is a self-contained ID factory — like giving each post office its own stamp machine with a unique prefix. No two machines ever produce the same stamp, and you can read the timestamp and origin directly from the ID itself.
Follow-up Questions:
  1. How do you assign node IDs?
    • Zookeeper/etcd for coordination
    • Use MAC address hash
    • Use Kubernetes pod ordinal
  2. What if clock goes backwards?
    • Throw exception (let operator fix NTP)
    • Wait for clock to catch up
    • Use logical clock component
  3. 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

Difficulty: Very Hard
Companies: Confluent, AWS (SQS), LinkedIn
Time: 60 minutes

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

  1. Clarify requirements (5 min)
    • Scale: Users, requests/second, data size
    • Consistency: Strong or eventual?
    • Latency: What’s acceptable?
  2. High-level design (10 min)
    • Draw boxes and arrows
    • Identify core components
    • Explain data flow
  3. Deep dive (20 min)
    • Pick 2-3 most critical components
    • Discuss algorithms, data structures
    • Explain trade-offs
  4. Handle edge cases (10 min)
    • Failures: Node crashes, network partitions
    • Scale: Hot spots, bottlenecks
    • Consistency: Race conditions
  • 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?
  • 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.)