Skip to content
ML SystemPart 5: Case StudiesChapter 5
Case Studies CH.05 ~20 min

Case Studies

Interview methodology, Twitter Timeline, and Instagram Storage.

interviewback-of-the-envelopeTwitter architectureInstagram architecture
  • Execute system design steps methodically.
  • Perform rough storage and bandwidth capacity estimations.
  • Analyze Twitter and Instagram architectures.
  • Evaluate trade-offs in implementing fan-out features.

01 Design Methodology: Thinking Like an Architect Viz

  1. **Clarification**: Ask about system constraints (DAU, Read/Write ratio).
  2. **Estimation**: Roughly calculate storage and bandwidth needs (Back-of-the-envelope).
  3. **High-level Design**: Sketch the main flow (User -> Load Balancer -> App -> DB).
  4. **Component Detail**: Discuss sharding, caching, and queues in depth.
  5. **Trade-off Discussion**: Explain why you chose that particular solution.
Rough Calculations

Use 'Powers of Two' for quick estimations. For example: 2^20 is ~1 million, 2^30 is ~1 billion.

Back-of-the-envelope calculation

A rough estimate performed quickly to validate a design idea.

02 Case Study 1: Designing Twitter (Timeline)

Deeper InsightYour timeline is actually pre-computed before you even open it. Click to collapse

Simplified architecture of Twitter's main features.
FeatureChallengeSolution
Posting TweetHigh trafficQueueing & Async Write
Reading TimelineLow latencyRedis Pre-computed Timeline
SearchKeyword indexingElasticsearch / Lucene

Simplified architecture of Twitter's main features.

03 Case Study 2: Designing Instagram (Photos & Feed)

  • **Object Storage**: For raw image/video files.
  • **Graph Database**: To map 'Follow' and 'Like' relationships.
  • **CDN**: Essential for fast photo delivery worldwide.
Final Advice

Learn from failures. Read engineering post-mortems from large companies to understand how systems fail at scale.

Key Takeaways

  1. 1Always start with requirement clarification before designing.
  2. 2Capacity estimation helps you choose the right technology from the start.
  3. 3Every major application (Twitter, Instagram) has unique challenges requiring specific solutions.
  4. 4Learning from real-world architectures is the best way to master system design.

CH.05

Chapter Complete

Chapter Progress

Reading
Exercise

Interact with the visualization

Quiz

Methodology & Case Studies Quiz

Test your understanding of the system design process and real-world case studies.

Ready to test your knowledge?

5 questionsRandomized from pool70% to pass