This is basically a full system design gauntlet in one question.
Start by clarifying requirements and scale (e.g., 500M users, read-heavy, eventual consistency acceptable). Then walk through a high-level design covering data modeling, core interactions, feed generation, storage, search/trending, and scaling, making trade-offs explicit at each step. Conclude by summarizing how components work together and potential bottlenecks.
Pro tip: Emphasize the read-heavy nature and propose a hybrid feed approach: push (fan-out on write) for active users and pull (fan-out on read) for celebrities, showing you understand the trade-off between latency and cost. Also, mention how Disney's need for real-time engagement (e.g., live events) might influence design choices like trending algorithms.
Ask questions to understand functional and non-functional requirements: user base size, read/write ratio, latency, consistency, and features like tweets, follows, timeline, search, and trending. Establish scale targets (e.g., 500M users, 500M tweets/day).
Design schemas for users, tweets, follows, and likes. Choose appropriate storage: SQL for user data (ACID), NoSQL (e.g., Cassandra) for tweets and timelines (high write throughput), and graph DB for social graph. Discuss sharding and replication.
Detail posting tweets, following, and timeline retrieval. Explain feed generation: fan-out on write for most users, fan-out on read for celebrities, using a hybrid approach. Discuss caching (Redis) for timelines and tweet objects.
Describe indexing tweets for search (e.g., Elasticsearch) and computing trends using streaming analytics (e.g., Apache Storm, Flink) with sliding windows. Discuss ranking and personalization.
Explain horizontal scaling, partitioning, CDN for media, and load balancing. Discuss consistency vs. availability (CAP theorem) and latency vs. cost. Address bottlenecks like hotkeys and celebrity problem.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.