Doc Collaboration
Doc Collaboration with personalized feeds, graph edges, and engagement.
Requirements
Functional Requirements
- Publish posts
- Render personalized timelines
- Record engagement
Non-functional Requirements
- Low p95 read latency
- Freshness within seconds
High-Level Design
- Write → fanout → timeline store → rank
Capacity & Sizing
- Posts/sec, followers distribution, timeline storage
Key Components
- Write service, Fanout, Ranking, Timeline store
Architecture
High-level components and data flow
Data Model
Core entities and relationships
- posts (
post_id PK,author_id,ts,body) - edges (
follower_id,followee_id) - timeline (
user_id,post_id,score,ts)
APIs
- POST /api/posts { body }
- GET /api/timeline?user=..
- POST /api/posts/:id/like
Hot Path
- Read → candidate select → rank → cache
Caching & TTL
- Cache timelines for seconds; invalidate on new posts
Scaling
- Hybrid fanout by follower count
- Cache user timelines
- Async recompute
Trade-offs
- Freshness vs cost
- Staleness windows
- Cold start
Failure Modes & Mitigations
- Ranking outage → recency
- Cache storms → jittered refresh
- Mega influencers → isolation
Observability
- p95 read latency
- cache hit ratio
- fanout lag