Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Zalando Engineering 9 min read Case study hardMaster

Why We Ditched Flink Table API Joins: Cutting State by 75% with DataStream Unions

Chained Flink 1.20 Table API/SQL joins amplified state because each join operator keeps its own copy of upstream records in RocksDB, pushing Zalando's Product Offer Enrichment jobs to about 240GB of state. Hourly savepoints then pinned CPU at 100%, caused backpressure, crash-restart loops and failed snapshots, and forced 10–20% overprovisioning on AWS Managed Flink. Replacing the join chain with a union of all streams into one DataStream, processed by a single keyed process function holding one ValueState per SKU with timestamp-based filtering and deduplication, cut state to 56GB and snapshot time from 11 to 2.5 minutes. AWS cost fell only 13%, because KPU billing tracks CPU and memory rather than state size. The same idea ships in Flink 2.1 as the experimental Multi-Way Join operator.

Related posts

  • From Homegrown to Flink: Migrating a Stateful Ad Event Join at Scale

    Zalando Engineering hardMaster

    Zalando'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 mediumAdept

    Lessons 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.

  • Reducing BigQuery Costs: How We Fixed A $1 Million Query

    Shopify Engineering mediumAdept

    Clustering a BigQuery table on two columns used in a query's WHERE clause cut the data scanned per query from about 75 GB to roughly 100–500 MB, turning a projected ~$949K/month bill into about $1,370/month. The query came from a Flink pipeline for a Shopify marketing tool. To avoid ingesting an ever-growing billion-row dataset into RocksDB state, the pipeline was being redesigned to offload queries to BigQuery at an estimated 60 requests per minute. Other cost tips: avoid SELECT *, partition tables, and use free table previews instead of exploratory queries.

  • Scaling SaaS security: Reco’s migration from Postgres to ClickHouse Cloud

    ClickHouse mediumAdept

    Reco, a SaaS security platform ingesting 10-12 billion JSON events weekly, moved over 90% of its workload from Postgres to ClickHouse Cloud. Running both databases synced via CDC had made schema migrations, updates, deletes and VACUUM painful. Reco replaced RDBMS features with ReplacingMergeTree and CollapsingMergeTree for upserts and deletes, idempotency and eventual consistency instead of transactions, and tenant-level atomic materialized view refreshes via REPLACE PARTITION. Further gains came from compute-compute separation, spill-to-disk settings, parallel_distributed_insert_select=2 (cutting resource needs by a third) and data-skipping indexes, plus using the EmbeddedRocksDB engine as a streaming state store in place of Spark state and Redis.

  • Goldsky - A Gold Standard Architecture with ClickHouse and Redpanda

    ClickHouse mediumAdept

    Goldsky streams blockchain data to potentially thousands of customer ClickHouse clusters by indexing chains into per-data-type Redpanda topics (Avro, infinite retention via tiered storage), applying per-customer FlinkSQL filters, joins and aggregations in stream at up to 500k events/sec, and delivering results to ClickHouse. Backfills use a custom hybrid Flink source that reads history from ClickHouse and increments from Redpanda. The main ClickHouse lesson was tuning ReplacingMergeTree for duplicates and updates: emulating PREWHERE, partitioning, limiting FINAL threads and customer-specific ORDER BY keys. The Base chain dataset (over 1B trace rows, roughly 1 TiB uncompressed) is publicly queryable at sql.clickhouse.com.

The quest for software engineering knowledge.

Look:
Layout: