Skip to content

CONCEPT Cited by 1 source

Flink KeyedCoProcessFunction

Definition

KeyedCoProcessFunction is a low-level Flink DataStream API primitive that processes elements from two connected keyed streams with access to per-key state and timers. Unlike high-level join operators (Interval Join, Window Join), it gives full control over matching logic, state management, and expiration strategy.

Why it matters

High-level join operators like Interval Join impose their own state management and expiry mechanisms that may be pathological for specific access patterns. KeyedCoProcessFunction allows:

  • Direct point lookups in RocksDB (no iterator/seek) when keys are unique
  • Custom expiry via RocksDB TTL compaction instead of per-element timer registration
  • Asymmetric logic — different handling for each stream's elements

Seen in

Trade-offs

  • Pro: Full algorithmic control, optimal for unique-key workloads, no hidden seek/timer overhead
  • Con: More code to write and maintain; correctness burden shifts from framework to developer; no built-in watermark-based window semantics
  • When to use: Unique-key or low-cardinality-per-key partitions where high-level operators' generic algorithms produce pathological overhead
Last updated · 595 distilled / 1,807 read