Wrap Up
In this chapter, we designed a news feed system. Our design contains two flows: feed publishing and news feed retrieval.
Like any system design interview questions, there is no perfect way to design a system. Every company has its unique constraints, and you must design a system to fit those constraints. Understanding the tradeoffs of your design and technology choices are important. If there are a few minutes left, you can talk about scalability issues. To avoid duplicated discussion, only high-level talking points are listed below.
Scaling the database:
-
Vertical scaling vs Horizontal scaling
-
SQL vs NoSQL
-
Master-slave replication
-
Read replicas
-
Consistency models
-
Database sharding
Other talking points:
-
Keep web tier stateless
-
Cache data as much as you can
-
Support multiple data centers
-
Loosely coupled components with message queues
-
Monitor key metrics. For instance, QPS during peak hours and latency while users refreshing their news feed are interesting to monitor.
Congratulations on getting this far! Now give yourself a pat on the back. Good job!
Reference materials
- How News Feed Works: https://www.facebook.com/help/327131014036297/
- Friend of Friend recommendations Neo4j and SQL Sever: http://geekswithblogs.net/brendonpage/archive/2015/10/26/friend-of-friend-recommendations-with-neo4j.aspx
Finished reading?
Mark it complete to track your progress.