← DoorDash Interview InsightsSoftware Engineer
I started with the functional requirements which felt right, but I spent too long on the basic tweet storage part before getting to the interesting stuff.
Start by clarifying requirements and scale (e.g., 500M users, 10K tweets/sec), then design the data model and APIs for core entities (users, tweets, follows, likes). Focus on the home timeline generation strategy (fan-out on write vs. read vs. hybrid) and discuss trade-offs, caching, and storage choices for high availability and low latency.
Pro tip: Explicitly call out the celebrity problem and propose a hybrid fan-out approach: push tweets to followers for normal users, but pull tweets from celebrities at read time. This shows you understand real-world scaling challenges beyond textbook solutions.
Ask about functional requirements (post, follow, timeline, likes, retweets, replies) and non-functional requirements (latency, availability, consistency). Estimate scale: daily active users, tweets per second, read/write ratio, and storage needs.
Define core entities (User, Tweet, Follow, Like, Retweet, Reply) and their relationships. Sketch key APIs (e.g., POST /tweet, GET /timeline) and choose appropriate storage: SQL for user data, NoSQL or graph DB for social graph, and time-series or wide-column store for tweets.
Compare fan-out on write (push) vs. fan-out on read (pull) vs. hybrid. Discuss how to handle the celebrity problem, and design the home timeline service with caching (e.g., Redis) for fast retrieval.
Design how likes, retweets, and replies are stored and counted (e.g., counters in Redis, eventual consistency). Discuss how replies form threads and how retweets appear in timelines.
Cover partitioning (sharding by user ID), replication, caching layers, and CDN for media. Explain trade-offs between consistency and availability (CAP theorem), and how to handle failures and hot spots.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
This came naturally out of the main design question but they pushed on it separately.
Start by clarifying the scale and specific non-functional requirements (latency targets, consistency tolerance). Then propose a hybrid architecture that separates the write path (fanout) from the read path (timeline), using asynchronous processing and caching to meet low-latency reads while accepting eventual consistency for fanout. Finally, discuss trade-offs and mitigation strategies like idempotency, deduplication, and monitoring.
Pro tip: Acknowledge that perfect consistency at this scale is impractical; instead, focus on defining acceptable staleness bounds and designing for graceful degradation. Show you understand that user experience often tolerates eventual consistency if the timeline is mostly up-to-date.
Ask about expected read latency (e.g., <100ms), write throughput, and how stale the timeline can be. Confirm the scale of hundreds of millions of users and the fanout ratio (e.g., average followers per user).
Propose an asynchronous fanout service that processes events from a queue (e.g., Kafka) and writes to each follower's timeline store. Use partitioning and sharding to distribute load, and consider a hybrid push-pull model for celebrities.
Store precomputed timelines in a low-latency data store (e.g., Redis, Cassandra) with appropriate indexing. Use caching (CDN, in-memory) and read replicas to serve reads quickly, and consider denormalization for fast access.
Explain that fanout is eventually consistent: writes propagate asynchronously, so timelines may lag. Discuss how to handle conflicts (e.g., last-write-wins, vector clocks) and ensure idempotency to avoid duplicates.
Propose monitoring for fanout lag, error rates, and latency. Implement backpressure, retries with exponential backoff, and dead-letter queues. Consider fallback to pull-based model during outages.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.
Talked through adjacency list storage in a relational DB with a separate graph store for traversal at scale.
Start by clarifying the scale and requirements (e.g., number of users, read/write ratio, latency SLAs), then propose a hybrid storage approach: a graph database or adjacency lists for the social graph, and a denormalized timeline cache for fast reads. Discuss trade-offs between push (fan-out on write) and pull (fan-out on read) models, and how to handle celebrities or high-degree nodes.
Pro tip: Mention that you would use a hybrid fan-out strategy: push for normal users and pull for celebrities, and that you would leverage a distributed cache like Redis for timeline storage with a fallback to a durable store like Cassandra. This shows you understand real-world trade-offs at scale.
Ask about the number of users, average follows per user, read/write ratio, and latency requirements. This determines whether to optimize for reads or writes.
Propose storing the graph as adjacency lists in a distributed database (e.g., Cassandra) or a graph database (e.g., Neo4j). Discuss partitioning by user ID and using composite keys for follow relationships.
Compare push (fan-out on write) vs. pull (fan-out on read) models. Recommend a hybrid approach: push for most users, pull for high-degree users (celebrities) to avoid write amplification.
Use a fast in-memory store like Redis to cache precomputed timelines for active users, with a durable store (e.g., Cassandra) for persistence. Discuss TTL and eviction policies.
Explain how to handle eventual consistency, idempotent operations for follow/unfollow, and sharding strategies. Mention monitoring and backpressure to handle spikes.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.