A demo showcasing real-time data distribution using Cloudflare Workers, Durable Objects, and WebSocket fanout architecture.
| Symbol | Price | Change | Volume | Ingest | Master | Shard | Received | Total |
|---|
Waiting for market data...
Data source → singleton DO aggregates & fans out to regional shard DOs → each shard pushes to thousands of browser clients via Hibernatable WebSockets.
Historical data served from D1 with Cache API auto-invalidation.
One write path, global read path, zero infrastructure to manage.
Singleton Durable Object connects directly to Binance WebSocket. Aggregates trades into 1-minute K-line bars and maintains real-time price snapshots — all in-memory, zero external dependencies.
Per-region Durable Objects subscribe to Master via WebSocket. Each shard handles up to 10K browser connections using Hibernatable WebSockets — wake on message, broadcast, sleep.
Completed K-line bars write to D1 edge SQL database. REST queries cached via Cache API with minute-boundary auto-invalidation. Zero CDN config, zero stale data.
250ms bar snapshots pushed via WebSocket — the Binance model. No client-side aggregation, no data gaps on reconnect. Current bar from WS, history from REST.
At 1M concurrent users pushing real-time data, AWS egress costs can be significant at scale — often the single largest line item on the bill. Cloudflare charges $0 for egress. Combined with Hibernatable WebSockets that let idle shards sleep between pushes, compute cost drops further. This demo pushes at full speed to showcase real-time capability; production deployments can tune push frequency to optimize cost significantly.
No Kafka, no EC2 clusters, no load balancers. One wrangler deploy gives you global real-time infrastructure. From code to production in seconds — freeing your team to focus on product instead of operations.