大規模システムの設計には、多くのコンセプトを組み合わせることが必要です — 膨大なスケールの処理、適切なアーキテクチャの選択、データベース、キャッシング、およびトレードオフの管理です。具体的な例(ソーシャルメディアフィード)を使うことで、これらの要素がどのように組み合わさるかを示すことができます。
例:ソーシャルメディアニュースフィード
Requirements: millions of users; post content; see a feed of followed users' posts;
read-HEAVY (far more feed views than posts); low latency; high availability.
High-level components:
→ CLIENTS → LOAD BALANCER → APPLICATION servers (stateless, horizontally scaled)
→ DATABASES → user/post data (sharded); a graph of follows
→ CACHING (Redis) → hot feeds, posts, user data (crucial for read-heavy load)
→ CDN → media (images/videos)
→ MESSAGE QUEUES → async work (fan-out, notifications)
主要な設計決定:フィード生成
FAN-OUT ON WRITE (push) → when a user posts, push it to all followers' precomputed feeds:
✓ fast feed READS (precomputed) ✗ expensive for users with millions of followers
(write amplification)
FAN-OUT ON READ (pull) → build the feed when requested (query followed users' posts):
✓ cheap writes ✗ slower reads (compute on demand)
HYBRID → push for most; pull for celebrities (huge followings) → balances the trade-offs
→ illustrates analyzing trade-offs for the specific scale/pattern.
