Design a scalable food news feed
Company: DoorDash
Role: Software Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
##### Question
Design a news-feed feature for a food discovery app (DoorDash-style). The feed lists items showing **title, author, short summary, and engagement counts (comments, likes/saves)**, and tapping an item opens a **detail view** with the full description, comments, and related items. Cover the full system end to end:
1. **Data model & storage.** Define the entities (posts, comments, reactions/likes/saves, users, follows if needed, materialized counters, and a per-user or per-segment feed). Specify the storage choice for each (relational core vs. wide-row NoSQL vs. Redis) and the denormalized/materialized views you keep.
2. **APIs & pagination.** Read/write endpoints: list feed, fetch post detail, create/update post, create/update comment, toggle reaction, and search/filter. Use cursor-based (keyset) pagination and infinite scroll. Show the request/response shape and how cursors are encoded.
3. **Ranking.** Rank by recency + engagement. Give a concrete scoring formula with time decay and explain how scores are updated as engagement arrives.
4. **End-to-end request path.** Trace a request after it enters the system: edge/CDN, API gateway (auth, rate limiting), the stateless app tier, caches, OLTP/NoSQL stores, background workers, and the message queue / event bus. Do this for the **feed read**, the **post-detail read**, the **comment/reaction write**, and the **new-post create path**.
5. **New-post propagation.** Describe how a newly created post is processed and propagated into user feeds — including a fan-out strategy (fan-out-on-write vs. fan-out-on-read, and how you handle very-high-follower / celebrity authors).
6. **Caching, indexing & denormalization** for fast reads (hot-feed caches, counter caches, search index, author-snippet denormalization, hot-key protection).
7. **Search & filter** (e.g. by cuisine, city, tags, author) backed by a search engine.
8. **Scalability & resilience.** Partitioning/sharding, rate limiting, backpressure, circuit breakers, and graceful degradation.
9. **Consistency & idempotency.** Which paths are strongly vs. eventually consistent; read-your-writes for authors; idempotency keys for writes; idempotent counter aggregation.
10. **Error handling, retries, observability, and performance optimizations** (latency targets, batching, connection pooling, payload trimming, reconciliation jobs).
State your assumptions and rough traffic estimates, and call out the key trade-offs.
Quick Answer: A complete system-design walkthrough for a DoorDash-style food news feed: data model (posts, comments, reactions, follows, materialized feeds), cursor-paginated REST APIs, a recency-plus-engagement ranking formula, and the full end-to-end request path through CDN, gateway, app tier, caches, OLTP/NoSQL stores, and a Kafka event bus. Covers hybrid fan-out propagation for new posts, caching and denormalization, search/filter, partitioning, rate limiting and backpressure, consistency and idempotency, observability, and performance optimizations.