Bird
Raised Fist0
HLDsystem_design~20 mins

News feed generation in HLD - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
News Feed Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Design components for a scalable news feed system

Which of the following component sets best supports a scalable news feed generation system that handles millions of users with low latency?

AUser service, Feed generator, Cache layer, Database, Message queue
BUser service, Monolithic feed generator, Single database, No cache
CUser service, Feed generator, Cache layer, Multiple databases without queue
DUser service, Feed generator, Cache layer, Message queue, No database
Attempts:
2 left
💡 Hint

Think about components that help with asynchronous processing and fast data retrieval.

scaling
intermediate
2:00remaining
Handling high write throughput in news feed updates

When millions of users post updates simultaneously, which approach best handles the write load for news feed generation?

ABatch updates once a day to reduce write frequency
BDirectly write all updates synchronously to the main database
CStore updates only in cache without persistence
DUse a distributed message queue to buffer updates and process them asynchronously
Attempts:
2 left
💡 Hint

Consider how to smooth out spikes in write traffic.

tradeoff
advanced
2:00remaining
Tradeoffs between push and pull models in news feed generation

Which statement correctly describes a tradeoff between push and pull models for generating user news feeds?

APull model reduces latency but increases storage cost; push model reduces storage but increases latency
BPush model reduces latency but increases storage cost; pull model reduces storage but increases latency
CPush model increases latency and storage cost; pull model reduces both latency and storage
DPush and pull models have identical latency and storage costs
Attempts:
2 left
💡 Hint

Think about when feed data is prepared and stored.

🧠 Conceptual
advanced
2:00remaining
Impact of fan-out on news feed system design

What is the main challenge caused by high fan-out (users with millions of followers) in news feed generation?

AIt causes excessive read load on the database
BIt reduces the number of messages in the queue
CIt causes excessive write amplification and storage overhead
DIt simplifies feed generation logic
Attempts:
2 left
💡 Hint

Consider what happens when one user’s post must be delivered to many followers.

estimation
expert
3:00remaining
Estimating storage for a news feed system

Estimate the daily storage needed if 10 million users each post 2 updates per day, and each update is stored in the feeds of 500 followers. Each feed entry is 1 KB.

AApproximately 10 TB per day
BApproximately 5 TB per day
CApproximately 1 TB per day
DApproximately 20 TB per day
Attempts:
2 left
💡 Hint

Calculate total updates, multiply by followers, then by size.

Practice

(1/5)
1. What is the main purpose of a news feed generation system in social media platforms?
easy
A. To store user passwords securely
B. To manage user account settings
C. To show personalized and timely content to users
D. To handle payment transactions

Solution

  1. Step 1: Understand the role of news feed generation

    The news feed system is designed to deliver content that is relevant and timely to each user.
  2. Step 2: Identify the correct purpose among options

    The other options relate to security, settings, and payments, which are unrelated to news feed generation.
  3. Final Answer:

    To show personalized and timely content to users -> Option C
  4. Quick Check:

    News feed = personalized timely content [OK]
Hint: News feed = personalized content display [OK]
Common Mistakes:
  • Confusing news feed with user authentication
  • Mixing news feed with payment processing
  • Thinking news feed manages account settings
2. Which of the following is a common method used in news feed generation to deliver updates efficiently?
easy
A. Manual refresh by users only
B. Push model where updates are sent to users proactively
C. Storing all data in a single database without caching
D. Using FTP to transfer news feed data

Solution

  1. Step 1: Identify common delivery methods in news feed systems

    Push model proactively sends updates to users, improving latency and experience.
  2. Step 2: Evaluate other options for efficiency

    Manual refresh is user-driven and less efficient; no caching slows performance; FTP is unrelated to real-time feed delivery.
  3. Final Answer:

    Push model where updates are sent to users proactively -> Option B
  4. Quick Check:

    Push model = efficient update delivery [OK]
Hint: Push model proactively sends updates [OK]
Common Mistakes:
  • Assuming manual refresh is efficient
  • Ignoring caching benefits
  • Confusing FTP with real-time data delivery
3. Consider a news feed system using a pull model where users request their feed on demand. What is a likely outcome when many users request feeds simultaneously?
medium
A. Users receive outdated feeds only
B. Instant delivery with no server load
C. System automatically caches all feeds without delay
D. High latency and increased load on backend servers

Solution

  1. Step 1: Understand pull model behavior under load

    Pull model requires backend to generate feeds on request, causing high load if many users request simultaneously.
  2. Step 2: Analyze other options for feasibility

    Instant delivery with no load is unrealistic; outdated feeds depend on caching, not pull model alone; automatic caching without delay is ideal but not guaranteed.
  3. Final Answer:

    High latency and increased load on backend servers -> Option D
  4. Quick Check:

    Pull model + many requests = high load [OK]
Hint: Pull model causes backend load spikes [OK]
Common Mistakes:
  • Assuming pull model has no latency
  • Confusing caching with pull model behavior
  • Believing feeds are always instantly cached
4. A news feed system uses a push model but users report seeing stale content. Which is the most likely cause?
medium
A. Cache not invalidated after new content is pushed
B. Users are not refreshing their browsers
C. Backend servers are down
D. Users have slow internet connections

Solution

  1. Step 1: Identify push model behavior and caching role

    Push model sends updates, but if cache is not invalidated, users see old content.
  2. Step 2: Evaluate other options for staleness cause

    Browser refresh is less relevant in push; backend down causes no updates; slow internet delays but does not cause stale cached data.
  3. Final Answer:

    Cache not invalidated after new content is pushed -> Option A
  4. Quick Check:

    Push + stale feed = cache invalidation issue [OK]
Hint: Stale feed often means cache invalidation failed [OK]
Common Mistakes:
  • Blaming user refresh instead of cache
  • Ignoring cache invalidation importance
  • Assuming slow internet causes stale cache
5. You are designing a news feed system for a platform with 100 million users. Which approach best balances scalability and freshness of content?
hard
A. Hybrid model: push important updates and pull less critical content
B. Pure pull model: generate feed on every user request
C. Pure push model: push all updates to all users immediately
D. No caching: always fetch fresh data from database

Solution

  1. Step 1: Analyze scalability and freshness needs for large user base

    Pure pull causes high load; pure push is costly and complex; no caching is inefficient.
  2. Step 2: Evaluate hybrid model benefits

    Hybrid model pushes critical updates for freshness and uses pull for less urgent content, balancing load and latency.
  3. Final Answer:

    Hybrid model: push important updates and pull less critical content -> Option A
  4. Quick Check:

    Hybrid model balances scale and freshness [OK]
Hint: Hybrid push-pull balances scale and freshness [OK]
Common Mistakes:
  • Choosing pure pull causing backend overload
  • Choosing pure push causing network overload
  • Ignoring caching and load balancing