Design a home timeline (Twitter/Instagram style) that shows recent posts from accounts a user follows.
How to approach it
Sketch the request path from the client inward: client → edge/CDN → load balancer → stateless services → cache → database, with queues and workers off to the side for async work. Keep services stateless so they scale horizontally. Draw the happy path first; resilience and scale come after.
Components
| Component | Role |
|---|---|
| Client | app |
| Load Balancer | route requests |
| Post Service | write posts |
| Fan-out Worker | push posts to follower timelines |
| Queue | fan-out jobs |
| Timeline Cache | precomputed per-user feed (Redis) |
| Feed Service | read timeline, merge celebrity posts |
| Post Store | durable posts, sharded by author |
Request path
Client → Load Balancer → Feed Service → Timeline Cache → Post Store