本文由 AI 分析生成
建立時間: 2026-03-28 來源: https://zknill.io/posts/patterns-for-building-realtime/
Summary
Z. Knill’s breakdown of three patterns for realtime server-to-client data delivery: Poke/Pull (notify then fetch), Push State (send full updated state), and Push Ops (send operation deltas). Covers trade-offs: fan-out, state divergence risk, and CRDT complexity for collaborative features.
Z. Knill 對三種實時服務器到客戶端數據傳遞模式的分析:Poke/Pull(通知後獲取)、Push State(發送完整更新狀態)和 Push Ops(發送操作增量)。涵蓋取捨:扇出、狀態分歧風險和協作功能的 CRDT 複雜性。
Key Points
- Connection layer: websockets, SSE, event-streams, or polling — pattern is transport-agnostic; server needs to push without client polling
- Pattern 1 — Poke/Pull: server sends “poke” notification → client fetches new state via existing API; easy to add to existing apps; fan-out problem: all clients pull simultaneously → caching helps
- Pattern 2 — Push State: server sends full updated state; no fan-out problem; easy for clients (just replace state); bad for large states (small change = all data resent) and when clients need to know what changed
- Pattern 3 — Push Ops: server sends operation (e.g., “mark todo complete”); clients apply op locally; efficient transfers, explicit change semantics; complexity: operation ordering, conflict resolution → CRDTs for collaborative apps
- Extension: CRDTs (Conflict-free Replicated Data Types) for multi-writer scenarios; enable offline support and peer-to-peer sync
Insights
The three-pattern progression maps well to system maturity: start with Poke/Pull (minimal new infrastructure, reuse existing REST APIs), graduate to Push State when you need lower latency, advance to Push Ops when state is large or collaborative. The fan-out problem with Poke/Pull is solved by caching but requires synchronized cache invalidation logic. Push Ops + CRDTs is the foundation of local-first apps (Linear, Figma) where immediate local response and conflict-free multi-device sync matter more than server authority.
Connections
Raw Excerpt
Poke/pull is the easiest pattern to integrate into an existing app. When an update happens on the server, a ‘poke’ is sent to all subscribed clients notifying them to fetch the new state. Push ops makes it easier for clients to work out what has changed, and reduces the size of the data transferred.