Using Server Sent Events to Simplify Real-time Streaming at Scale
Shopify replaced its 2021 BFCM Live Map delivery path, in which WebSocket fed a presentation layer that clients polled through a mailbox system every 10+ seconds, with a Go Server Sent Events server. The server subscribes to Kafka topics produced by a Flink pipeline and pushes data straight to registered clients. SSE fit because the visualization only needs one-way, read-only push over plain HTTP with built-in reconnection; the server scales horizontally behind NGINX load balancers, and per-pod connection limits were sized with a Java load tester built on okhttp-eventsource. During BFCM 2022 the system had 100% uptime, SSE delivered data within milliseconds of availability, and end-to-end latency from event creation to display was about 21 seconds.
Related posts
- Scaling Shopify's BFCM Live Map: An Apache Flink Redesign
Shopify Engineering mediumAdeptShopify scaled its Black Friday/Cyber Monday live sales map by putting Apache Flink in front of Cricket, its home-grown Go stateful streaming service. Flink filtered the checkout Kafka stream so Cricket processed only about one percent of the events, and Flink also computed new metrics such as product trends and unique shoppers. The Flink jobs used cross-region sharding and active-active deployment, handled load tests of 1M events/sec and ran with 100% uptime through BFCM, with Spark batch jobs as a fallback. Redis used for broadcasting to browsers still became a bottleneck and briefly clogged in production, so the planned redesign moves all metrics into Flink and snapshots them to a store that a web tier serves from an in-memory cache.
- Web Streams at the Edge
Deno mediumAdeptDeno Deploy supports the Web Streams standard, so a streaming, event-driven HTTP server can be written in a few lines of TypeScript. Code examples cover an unbuffered HTTP proxy that passes request bodies straight through, a proxy that uppercases response text chunk by chunk with TransformStream, TextDecoderStream and TextEncoderStream, Server-Sent Events built from ReadableStream and setInterval with cleanup on cancel, and WebSockets via Deno.upgradeWebSocket. Because Deno Deploy serves over HTTP/2, SSE avoids the six-connection-per-host browser limit that makes it a poor fit on HTTP/1.1.
- Streaming Real-Time Visualizations with ClickHouse, Apache Arrow and Perspective
ClickHouse mediumAdept
A ~100-line browser demo streams forex tick data from ClickHouse into the Perspective visualization library (Rust/C++ compiled to WebAssembly) using Apache Arrow over HTTP. ClickHouse has no push or WebSocket API, so the client polls a sliding time window every ~30–50ms. The query filters on the primary-key timestamp and uses a window function over a slightly widened range to compute per-pair price change. Perspective keeps only the latest 20k rows. Queries run in under 10ms on 11.5B rows, latency is dominated by HTTP round trips, and 20 clients (~200 QPS) used under 2 cores. Polling can miss rows under eventual consistency and insert latency, which motivates planned streaming queries, and a full-dataset speed test uses the ArrowStream format with the Arrow JS library to feed data in chunks.
- GraphQL, meet LiveGraph: a real-time data system at scale
Figma mediumAdept
LiveGraph is Figma's real-time data layer on Postgres: frontend code declares GraphQL-like live queries via a React useSubscription hook, and the server keeps results updated by tailing the Postgres write-ahead log distributed over Kafka instead of polling. Each view is decomposed into a tree of join-free single-table subqueries. An index of active subqueries routes replication-stream changes to the right cached results, and subqueries are shared across users to cut database load. The client is isomorphic with the NodeJS server and receives ordered, exactly-once incremental updates, with permission checks and optimistic updates built in. Performance-critical parts are written in Go, a single instance currently handles about 10,000 writes/second, and open problems include sharding, thundering-herd reconnects after deploys, and pagination of live views.
- Leveraging Go Worker Pools to Scale Server-side Data Sharing
Shopify Engineering mediumAdeptShopify's Server Pixels service, a Go pipeline that consumes over a billion customer events per day from Kafka, fell behind on consumer lag because it spawned an unbounded number of goroutines to process and produce event batches. Replacing that with a fixed-size worker pool fed by a jobs channel, built on a reusable Worker interface and shut down gracefully with context cancellation and WaitGroups, bounded resource use. Throughput per pod rose from 7.75k to 12.9k events/sec with 15 workers, 19.3k with 50, and 21k after further tuning, a 170% gain. That headroom carried the service through a 46k events/sec peak during BFCM 2021.