System Design AI

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

RequirementTypical 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 freshnessWithin 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

  1. Client request – Mobile or web app calls GET /feed?userId=XYZ&cursor=….
  2. API Gateway – Entry point that validates auth tokens and forwards to a Lambda function.
  3. 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.
  4. Cache lookup – For the most recent posts, the service checks ElastiCache (Redis) where a pre-computed “home timeline” is stored per user.
  5. Fan-out fallback – If the cache miss occurs, the service reads recent posts from DynamoDB and merges them with the follow list.
  6. Ranking – Simple score function (recency + engagement) runs in-memory; the result is paginated.
  7. Response – JSON payload returned through API Gateway to the client.

Data model highlights

  • Users table (DynamoDB) – Partition key userId, attribute followedIds (set). Fast lookup for the follow graph.
  • Posts table (DynamoDB) – Partition key postId, sort key timestamp. 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).
  • Identifies a single point of failure (the Lambda function) 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: DynamoDB reads at $0.25 per million RCUs vs. Redis memory at $0.10 per GB-hour; shows that a push-based cache saves orders of magnitude in read cost.
  • 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 – Uses TTL on Redis entries to keep only the last 24 hours, 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

MistakeWhy it hurts
Ignoring read-write imbalanceLeads to over-provisioned writes and throttled reads
Proposing a monolithic DB for both posts and timelinesCannot meet latency target; no horizontal scaling
Forgetting cache hit ratioMisses the biggest performance win; unrealistic latency estimates
Over-engineering with complex graph databasesAdds unnecessary operational burden for a simple follow graph
Not discussing consistencyLeaves interviewers unsure about user experience expectations

Level comparison table

AspectJunior AnswerSenior AnswerStaff Answer
Core servicesAPI Gateway, Lambda, DynamoDB, S3Adds ElastiCache (Redis) and Kafka on MSKAdds monitoring, automated scaling, cost modeling
Data flowPull-only from DynamoDBPush-based fan-out to Redis, read-through fallbackFull resilience: replication, circuit breakers, TTL eviction
ConsistencyStrong reads everywhereEventual consistency for timelinesExplicit SLA discussion, fallback to strong reads when needed
Ops & costBasic estimateDetailed RCUs vs. Redis costMonitoring, alarms, scaling policies, cost-benefit justification
Failure handlingNone or briefHandles cache miss, Kafka retryHandles node loss, throttling, security, disaster recovery

How to practice this

  1. Study the worked design for a news feed in the System Design AI library. Observe how the request path is built step by step.
  2. On the canvas, sketch your own feed architecture. Include the three levels of detail – junior, senior, staff – and label each AWS service.
  3. Use the practice brief rubric to evaluate whether you covered requirements, trade-offs, and failure modes. 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 writes once per post 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, and a TTL of about a day on Redis entries so memory stays bounded. Stale entries are evicted automatically, and a fallback read from DynamoDB ensures no post is missed.