Skip to main content
S2 streams can serve as the shared log that keeps data in sync — between clients, between services, or between databases and downstream consumers.

Event sourcing

Store events instead of current state. Append each change to a stream, and materialize state by replaying from the beginning — or from a known checkpoint. New consumers can be added at any time by reading the full history. S2’s strong consistency and durable total ordering of records make it a natural fit as a shared write-ahead log. See the kv-store blog post for a detailed example of how a replicated database with strong consistency can be built directly over the S2 primitive.

WebSockets alternative

S2 streams can replace stateful WebSocket connections for bidirectional communication. Use two streams (one per direction) or a single shared stream. Records are durable and ordered, clients can reconnect and resume from their last sequence number, and there’s no connection state to manage server-side.