advancedTop 30 Scenario-Based Questions

Design a social media feed system (like Twitter) handling 100M users.

Fanout on Write for celebrities vs Pull for normal users: 1) Write path: user posts tweet → stored in tweets:MongoDB. 2) Fanout on Write (< 1K followers): for each follower: LPUSH timeline:{followerId} tweetId. LTRIM to last 1000 tweets. 3) Celebrities (> 1K followers): don't fanout on write (too expensive). On read: merge celebrity tweets with personal timeline. 4) Read path: LRANGE timeline:user

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to A MongoDB collection has a compound index on {status:1, createdAt:-1} but queries with only createdAt are slow. Why?← Back to all NoSQL questions