Design a News Feed: Junior, Senior, and Staff Answers
When an interviewer asks you to design a news feed, they are looking for three things: how you translate vague user-experience goals into concrete system requirements, how you choose data stores and APIs to meet those requirements, and whether you can discuss the inevitable trade-offs. The question is a sandbox for scalability, consistency, and operational thinking.
What the interviewer is testing
- Requirement gathering – can you ask clarifying questions about latency, freshness, personalization, and read/write ratios?
- System decomposition – do you break the problem into request-path steps and identify the right AWS services for each?
- Trade-off analysis – are you comfortable discussing consistency vs. latency, cost vs. performance, and operational complexity?
Core requirements and driving numbers
| Requirement | Typical value (hedged) |
|---|---|
| Active users | ~100 million worldwide (order of 10⁸) |
| Read throughput | ~10 k reads/second (≈864 M reads/day) |
| Write throughput | ~1 k writes/second (≈86 M writes/day) |
| Latency target | <200 ms for a personalized feed |
| Data freshness | Within a few minutes for most posts |
These numbers guide the choice of storage, caching, and fan-out mechanisms. If you assume 100 M users, each user might generate a little under one post per day, giving roughly 86 M new posts daily. That translates to about 1 k writes/second – a modest figure, but the read side is the real pressure point.
The request path, step by step
- Client request – Mobile or web app calls
GET /feed?userId=XYZ&cursor=…. - API Gateway – Entry point that validates auth tokens and forwards to a Lambda function.
- Feed Service (Lambda) – Looks up the user’s follow list from DynamoDB (fast key-value reads). It then builds a list of candidate post IDs.
- Cache lookup – For the most recent posts, the service checks ElastiCache (Redis) where a pre-computed “home timeline” is stored per user.
- Fan-out fallback – If the cache miss occurs, the service reads recent posts from DynamoDB and merges them with the follow list.
- Ranking – Simple score function (recency + engagement) runs in-memory; the result is paginated.
- Response – JSON payload returned through API Gateway to the client.
Data model highlights
- Users table (DynamoDB) – Partition key
userId, attributefollowedIds(set). Fast lookup for the follow graph. - Posts table (DynamoDB) – Partition key authorId, sort key timestamp#postId, so one query returns an author's recent posts. Stores metadata; actual media lives in S3.
- Home timeline cache (Redis) – Key
timeline:userId→ list of post IDs ordered by score. Updated by a background fan-out worker. - Fan-out worker – Consumes new-post events from Kafka on MSK, writes the post ID into each follower’s Redis list. For very popular users, the worker skips the fan-out; readers pull those authors’ recent posts from DynamoDB at read time and merge them into the cached timeline.
What a complete junior answer covers
- Lists the basic components (API Gateway, Lambda, DynamoDB, S3).
- Draws a single request path without caching or fan-out.
- Mentions read/write ratios and a simple latency target.
- Shows a minimal data model (users and posts tables).
- Names what fails first under load (for example, DynamoDB throttling on hot reads) but does not elaborate on mitigation.
What a senior answer adds
- Introduces ElastiCache for a per-user home timeline, reducing DynamoDB read load.
- Explains a fan-out design using Kafka to push new posts to followers’ caches, turning many reads into writes.
- Discusses consistency: eventual consistency for the timeline cache, strong reads for a user’s own posts.
- Adds a fallback path that reads directly from DynamoDB when the cache is cold.
- Shows a simple cost estimate (e.g., DynamoDB read capacity units vs. Redis memory cost) and argues why the push model scales better as read traffic grows.
What a staff answer adds
- Failure modes – Handles cache node loss (Redis replication), Kafka broker failure (MSK automatic recovery), and DynamoDB throttling (exponential backoff, circuit breaker).
- Operational concerns – Monitoring via CloudWatch metrics (read latency, cache hit ratio), alarms for cache miss spikes, and automated scaling policies for Lambda and Redis.
- Cost analysis – Rough calculation from current price lists: DynamoDB read units for 10 k feed reads a second, each touching many posts, against the memory needed to hold every active user's timeline in Redis; shows when the push-based cache is cheaper.
- Trade-off defense – Defends eventual consistency for the home timeline, citing user tolerance for a few-minute stale content, and explains why a fully real-time pull model would blow up read capacity.
- Data eviction policy – Caps each timeline list (LTRIM to the newest few hundred post IDs) and sets a TTL on the timelines of inactive users, reducing memory pressure.
- Security – Mentions IAM roles for Lambda, VPC endpoints for DynamoDB, and encryption at rest for S3.
Common mistakes that sink the question
| Mistake | Why it hurts |
|---|---|
| Ignoring read-write imbalance | Leads to over-provisioned writes and throttled reads |
| Proposing a monolithic DB for both posts and timelines | Cannot meet latency target; no horizontal scaling |
| Forgetting cache hit ratio | Misses the biggest performance win; unrealistic latency estimates |
| Over-engineering with complex graph databases | Adds unnecessary operational burden for a simple follow graph |
| Not discussing consistency | Leaves interviewers unsure about user experience expectations |
Level comparison table
| Aspect | Junior Answer | Senior Answer | Staff Answer |
|---|---|---|---|
| Core services | API Gateway, Lambda, DynamoDB, S3 | Adds ElastiCache (Redis) and Kafka on MSK | Adds monitoring, automated scaling, cost modeling |
| Data flow | Pull-only from DynamoDB | Push-based fan-out to Redis, read-through fallback | Full resilience: replication, circuit breakers, TTL eviction |
| Consistency | Strong reads everywhere | Eventual consistency for timelines | Explicit SLA discussion, fallback to strong reads when needed |
| Ops & cost | Basic estimate | Detailed RCUs vs. Redis cost | Monitoring, alarms, scaling policies, cost-benefit justification |
| Failure handling | None or brief | Handles cache miss, Kafka retry | Handles node loss, throttling, security, disaster recovery |
How to practice this
- Read the free worked design, Design a News Feed: start with the board for your level and observe how the request path is built step by step.
- On paper or a whiteboard, sketch your own feed architecture. Include the three levels of detail – junior, senior, staff – and label each AWS service.
- Check whether you covered requirements, trade-offs, and failure modes; with Pro ($10/month), draw it on the practice canvas and have the Coach review it against the practice brief’s rubric. Iterate until the senior and staff sections feel complete.
Questions people ask
What latency should a news feed aim for?
A typical target is under 200 ms for a personalized feed. This balances user experience with the cost of aggressive caching.
Why use a push-based fan-out instead of pulling every post on each request?
Pulling scales linearly with read traffic; a push model does the work once per post at write time (one insert per follower's timeline) and serves many reads from cache, dramatically reducing read-heavy load.
Can DynamoDB handle the write rate for 100 M users?
Yes, if you partition by user ID and use on-demand capacity or provisioned WCUs with auto-scaling. The write rate (≈1 k writes/second) is well within DynamoDB’s capabilities.
How do you keep the timeline fresh without overwhelming the cache?
Use a background worker that pushes new posts to the cache as they arrive, trim each timeline to its newest few hundred entries, and set a TTL on inactive users' timelines so memory stays bounded. A fallback read from DynamoDB rebuilds an expired timeline, so no post is missed.