Scaling Shopify's BFCM Live Map: An Apache Flink Redesign
Shopify 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.
Related posts
- How we prepare Shopify for BFCM
Shopify Engineering mediumAdeptShopify readies for Black Friday Cyber Monday with a year-long program that runs from March to October. It combines capacity planning on Google Cloud, What Could Go Wrong risk assessments, chaos-engineering Game Days on critical journeys like checkout, and a centralized Resiliency Matrix of failure modes, RTOs and runbooks. Five scale tests at forecast and p99 load (up to 200M requests per minute) used the Genghis load generator from three GCP regions, Toxiproxy fault injection and regional failovers. The tests surfaced issues such as checkout queue backups, rate-limit paths in authenticated checkout and slow region rebalancing. The newly rebuilt analytics platform needed more Kafka partitions, API memory optimization, connection-timeout tuning and load-balancer changes before facing its first holiday peak.
- From Homegrown to Flink: Migrating a Stateful Ad Event Join at Scale
Zalando Engineering hardMasterZalando's Ad Platform team replaced a 7-year-old homegrown Java service that joins ad auction (bid) events with user interaction events within a 15-minute window with an Apache Flink pipeline using RocksDB state and incremental checkpoints. Flink's built-in interval join spent 15-30% of CPU on RocksDB seeks and maintained a ~70M-entry timer queue, so the team wrote a KeyedCoProcessFunction with two ValueStates keyed by unique bid ID and TTL-based compaction cleanup, cutting the join operator from 30-60 subtasks and 150-300GB memory to 10 subtasks and 50GB. The post also covers RocksDB compaction tuning to stop state growth, a custom Kinesis deaggregation layer, Enhanced Fan-Out throttling issues, Karpenter evicting pods during Flink rescales, kernel OOM kills fixed by raising JVM overhead and lowering managed memory, and a four-week shadow pipeline plus A/B test before cutover.
- 7 Tips For Optimizing Apache Flink Applications
Shopify Engineering mediumAdeptLessons from running large stateful Apache Flink jobs (up to 13 TB of state) on GKE with the RocksDB state backend and checkpoints on GCS. Disabling Kryo fallback and fixing the serialization failures it exposed, such as Scala BigDecimal and sealed-trait ADTs, raised throughput by 20%. Keying records by partition before the File Sink cut active buckets per Task Manager by 90% and ended heap OOMs, and local SSDs for RocksDB gave about a 10x processing speedup over NFS. Further tips cover separate config profiles for backfill and steady state (partitions, network buffers, checkpoint intervals), avoiding dynamic classloading to stop Metaspace leaks on restart, and profiling with async-profiler, VisualVM, jemalloc/jeprof and Eclipse MAT.
- 3 (More) Tips for Optimizing Apache Flink Applications
Shopify Engineering mediumAdeptThree practices for tuning large stateful Apache Flink jobs, drawn from Shopify's streaming platform. Size parallelism so task managers × slots per task manager is equal to or slightly above the highest operator parallelism (e.g. 25 TMs × 4 slots for parallelism 100), starting with a single environment-level value. Prevent sink backpressure with batched writes (Kafka batch.size, Bigtable bulk mutations) and fix keyBy skew by appending a random bucket to hot or low-cardinality keys, then re-aggregating. Use HybridSource to present archived object-storage data and live Kafka topics as one ordered DataStream, which also speeds backfills because the archives have far more partitions.
- Using Server Sent Events to Simplify Real-time Streaming at Scale
Shopify Engineering mediumAdeptShopify 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.