G19 · Design Google Docs Realtime Collaboration G19 · 设计 Google Docs 实时协作
Verified source经核实出处
Google Docs is canonical realtime collab; SD interview classic. Credibility A.
Key decisions关键决策
- **Operational Transformation** (Google's original) or **CRDT** (modern). OT needs server authoritative; CRDT allows P2P.**OT**(Google 原版) 或 **CRDT**(现代)。OT 需服务端权威;CRDT 可 P2P。
- **Per-document fan-out**: WebSocket session, server sequences ops, broadcasts to other clients.**按文档 fan-out**:WS 会话,服务端定序 op,再广播。
- **Offline queue**: local CRDT/OT state; reconcile on reconnect.**离线队列**:本地 CRDT/OT;重连时对齐。
- **History**: compressed op log; replay for timeline view.**历史**:压缩 op 日志;重放用于时间线。
Follow-ups追问
- Presence scale? heartbeat + short-TTL cache.在线状态规模?心跳 + 短 TTL 缓存。