Durable Streams
lastmod 2025-12-24created 2025-12-242 edits
An open protocol for real-time sync for client applications
About
- An HTTP-based durable streaming protocol that reliably delivers data to web browsers, mobile, and native clients
- Supports a simple, proven way to create and consume ordered, replayable streams
- Offset-based resumption lets clients pick up from where they left off even if the connection drops
- Used for a variety of real-time scenarios such as AI chat streaming, database sync, collaborative editing, event sourcing, and workflow execution
- Solves the connection instability problems of existing WebSocket and SSE
- Refresh-safe design resumes from the same position even after switching tabs or sending the app to the background
- URL-based stream sharing lets multiple users watch the same stream simultaneously
- Cost-saving, CDN-friendly architecture can handle millions of concurrent connections from a single origin
- Supports multi-device and multi-tab sync
- An Apache 2.0-licensed protocol that the Electric SQL team has proven in production for 1.5 years
Protocol features
- Universal: usable in any environment where HTTP works
- Simple: based on standard HTTP, no custom protocol needed
- Resumable: supports offset-based reads and resumption
- Real-time: real-time tailing via Long-poll and SSE modes
- Economical: efficient scalability through CDN caching
- Composable: higher-level abstraction layers can be built on top (e.g., Electric's real-time Postgres sync engine)
Performance characteristics
- Latency under 15ms, handles millions of concurrent subscribers, horizontal scalability
- Offset-based URL structure maximizes use of CDN caching
Relationship with backend streaming systems
- Complements server-to-server messaging systems such as Kafka, RabbitMQ, and Kinesis
- Durable Streams handles the client delivery layer
- The server performs authentication and data transformation, and Durable Streams fans it out over HTTP
Differences from SSE and WebSocket
- SSE/WebSocket provide a simple connection, while Durable Streams provides a durable log-based structure
- Combines the advantages of a standardized log, such as offset resumption, history replay, and multiple-reader support
Implementation flexibility
- A server can be built in any language by implementing just the HTTP API, durable storage, and offset management
- Provides a Node.js reference server plus conformance test and benchmark tools
Key use cases
- Real-time database sync: streaming Postgres changes to web and mobile
- Event sourcing systems: restoring state from a durable event log
- AI chat streaming: LLM token streams can be resumed without interruption