Skip to content

CONCEPT Cited by 1 source

Flink memory tuning

Definition

The practice of configuring Flink's multi-layered JVM memory model to prevent Linux kernel OOM kills while maximising available state storage. Flink's memory model divides pod memory into: framework heap/off-heap, task heap/off-heap, managed memory (RocksDB cache/sort buffers), JVM metaspace, and JVM overhead (native allocations including RocksDB's own memory).

Why kernel OOM kills happen

Flink pods run as a single JVM process. When RocksDB (C++ via JNI) allocates native memory outside the JVM's tracked regions, the process can exceed the pod's memory limit without triggering a Java OutOfMemoryError. The Linux kernel terminates the process via OOM-killer โ€” no graceful handling, entire pod lost.

Key parameters

Parameter Typical default Production tuning
taskmanager.memory.jvm-overhead.fraction 0.1 0.2
taskmanager.memory.jvm-overhead.max 1 GB 4 GB
taskmanager.memory.managed.fraction 0.4 0.6 (reduce if RocksDB native memory is high)
taskmanager.memory.jvm-metaspace.size 256 MB 256 MB

Seen in

Lessons

  • Flink's auto-tuning log recommendations are a starting point, not final values
  • RocksDB native memory is the unpredictable component โ€” always leave a buffer
  • CPU-to-memory ratio must be determined experimentally for each workload type (checkpointing workloads use more CPU than pure processing)
Last updated ยท 595 distilled / 1,807 read