---
title: "7 Tips For Optimizing Apache Flink Applications"
description: "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."
url: "https://swe.quest/articles/7-tips-for-optimizing-apache-flink-applications-be2dbc2fd7e74cd5"
canonical: "https://shopify.engineering/optimizing-apache-flink-applications-tips"
source: "Shopify Engineering"
published: "2022-03-08"
difficulty: "medium"
kind: "How-to"
reading_minutes: 14
tags: ["stream-processing","performance","jvm","debugging"]
---

# 7 Tips For Optimizing Apache Flink Applications

A post on [Shopify Engineering](https://swe.quest/sources/shopify.md), published 2022-03-08, 14 min read, How-to. Original: [https://shopify.engineering/optimizing-apache-flink-applications-tips](https://shopify.engineering/optimizing-apache-flink-applications-tips)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Stream processing](https://swe.quest/tags/stream-processing.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- Apache Flink basics ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))
- JVM memory model ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- Stream processing concepts ([easy posts on Stream processing](https://swe.quest/tags/stream-processing.md?difficulty=easy))

## Keywords

Apache Flink, RocksDB, Kryo, async-profiler, Eclipse MAT, jemalloc, Google Kubernetes Engine, Google Cloud Storage

## Related posts

- [From Homegrown to Flink: Migrating a Stateful Ad Event Join at Scale](https://swe.quest/articles/from-homegrown-to-flink-migrating-a-stateful-ad-event-join-at-scale-34697efa4030f6e1.md): Zalando Engineering · 2026-07-23 · Hard · 12 min read · Stream processing, Storage engines, Performance engineering, Kubernetes, Ads
  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.
- [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.
- [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.
- [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.

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)
