---
title: "From Homegrown to Flink: Migrating a Stateful Ad Event Join at Scale"
description: "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."
url: "https://swe.quest/articles/from-homegrown-to-flink-migrating-a-stateful-ad-event-join-at-scale-34697efa4030f6e1"
canonical: "https://engineering.zalando.com/posts/2026/07/migrating-ad-event-processing-to-flink.html"
source: "Zalando Engineering"
published: "2026-07-23"
difficulty: "hard"
kind: "Case study"
reading_minutes: 12
tags: ["stream-processing","storage-engines","performance","kubernetes","ads"]
---

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

A post on [Zalando Engineering](https://swe.quest/sources/zalando.md), published 2026-07-23, 12 min read, Case study. Original: [https://engineering.zalando.com/posts/2026/07/migrating-ad-event-processing-to-flink.html](https://engineering.zalando.com/posts/2026/07/migrating-ad-event-processing-to-flink.html)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Stream processing](https://swe.quest/tags/stream-processing.md) (Data & databases)
- [Storage engines](https://swe.quest/tags/storage-engines.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Kubernetes](https://swe.quest/tags/kubernetes.md) (Infrastructure)
- [Ads](https://swe.quest/tags/ads.md) (Domains)

## Prerequisites

- Apache Flink keyed state ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))
- stream joins and watermarks
- RocksDB basics
- Kafka/Kinesis consumers ([easy posts on Queues & messaging](https://swe.quest/tags/messaging.md?difficulty=easy))

## Keywords

Apache Flink, RocksDB, KeyedCoProcessFunction, Kinesis, Nakadi, Karpenter, Interval Join

## Related posts

- [7 Tips For Optimizing Apache Flink Applications](https://swe.quest/articles/7-tips-for-optimizing-apache-flink-applications-be2dbc2fd7e74cd5.md): Shopify Engineering · 2022-03-08 · Medium · 14 min read · Stream processing, Performance engineering, Java & JVM, Debugging
  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.
- [Why We Ditched Flink Table API Joins: Cutting State by 75% with DataStream Unions](https://swe.quest/articles/why-we-ditched-flink-table-api-joins-cutting-state-by-75-with-datastream-unions-939c1fa5429761f5.md): Zalando Engineering · 2026-03-03 · Hard · 9 min read · Stream processing, Performance engineering, Cost optimization, Cloud platforms
  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.
- [Scaling Shopify's BFCM Live Map: An Apache Flink Redesign](https://swe.quest/articles/scaling-shopify-s-bfcm-live-map-an-apache-flink-redesign-bcbe156fa7990bd0.md): Shopify Engineering · 2021-12-10 · Medium · 9 min read · Stream processing, Scaling, System design, Real-time systems
  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.
- [Rerouting the Stream: How Lyft Moved to the Apache Flink Kubernetes Operator](https://swe.quest/articles/rerouting-the-stream-how-lyft-moved-to-the-apache-flink-kubernetes-operator-54f95160e73c8a70.md): Lyft Engineering · 2026-08-31 · Medium · 12 min read · Stream processing, Kubernetes, Deployment, Capacity planning, Cost optimization
  Lyft retired its homegrown Flink Kubernetes operator and moved hundreds of streaming jobs to the open-source Apache Flink Kubernetes Operator.
- [3 (More) Tips for Optimizing Apache Flink Applications](https://swe.quest/articles/3-more-tips-for-optimizing-apache-flink-applications-9c796b6721a565fb.md): Shopify Engineering · 2022-12-13 · Medium · 7 min read · Stream processing, Performance engineering, Queues & messaging
  Three practices for tuning large stateful Apache Flink jobs, drawn from Shopify's streaming platform.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
