Apache Flink
View on Wikipedia| Apache Flink | |
|---|---|
| Developer | Apache Software Foundation |
| Initial release | May 2011 |
| Stable release | |
| Repository | |
| Written in | Java and Scala |
| Operating system | Cross-platform |
| Type |
|
| License | Apache License 2.0 |
| Website | flink |
Apache Flink is an open-source, unified stream-processing and batch-processing framework developed by the Apache Software Foundation. The core of Apache Flink is a distributed streaming data-flow engine written in Java and Scala.[3][4] Flink executes arbitrary dataflow programs in a data-parallel and pipelined (hence task parallel) manner.[5] Flink's pipelined runtime system enables the execution of bulk/batch and stream processing programs.[6][7] Furthermore, Flink's runtime supports the execution of iterative algorithms natively.[8]
Flink provides a high-throughput, low-latency streaming engine[9] as well as support for event-time processing and state management. Flink applications are fault-tolerant in the event of machine failure and support exactly-once semantics.[10] Programs can be written in Java, Python,[11] and SQL[12] and are automatically compiled and optimized[13] into dataflow programs that are executed in a cluster or cloud environment.[14]
Flink does not provide its own data-storage system, but provides data-source and sink connectors to systems such as Apache Doris, Amazon Kinesis, Apache Kafka, HDFS, Apache Cassandra, and ElasticSearch.[15]
Development
[edit]Apache Flink is developed under the Apache License 2.0[16] by the Apache Flink Community within the Apache Software Foundation. The project is driven by 119[17] committers and over 340 contributors.
Overview
[edit]Apache Flink's dataflow programming model provides event-at-a-time processing on both finite and infinite datasets. At a basic level, Flink programs consist of streams and transformations. “Conceptually, a stream is a (potentially never-ending) flow of data records, and a transformation is an operation that takes one or more streams as input, and produces one or more output streams as a result.”[18]
Apache Flink includes two core APIs: a DataStream API for bounded or unbounded streams of data and a DataSet API for bounded data sets. Flink also offers a Table API, which is a SQL-like expression language for relational stream and batch processing that can be easily embedded in Flink's DataStream and DataSet APIs. The highest-level language supported by Flink is SQL, which is semantically similar to the Table API and represents programs as SQL query expressions.
Programming Model and Distributed Runtime
[edit]Upon execution, Flink programs are mapped to streaming dataflows.[18] Every Flink dataflow starts with one or more sources (a data input, e.g., a message queue or a file system) and ends with one or more sinks (a data output, e.g., a message queue, file system, or database). An arbitrary number of transformations can be performed on the stream. These streams can be arranged as a directed, acyclic dataflow graph, allowing an application to branch and merge dataflows.
Flink offers ready-built source and sink connectors with Apache Kafka, Amazon Kinesis,[19] HDFS, Apache Cassandra, and more.[15]
Flink programs run as a distributed system within a cluster and can be deployed in a standalone mode as well as on YARN, Mesos, Docker-based setups along with other resource management frameworks.[20]
State: Checkpoints, Savepoints, and Fault-tolerance
[edit]Apache Flink includes a lightweight fault tolerance mechanism based on distributed checkpoints.[10] A checkpoint is an automatic, asynchronous snapshot of the state of an application and the position in a source stream. In the case of a failure, a Flink program with checkpointing enabled will, upon recovery, resume processing from the last completed checkpoint, ensuring that Flink maintains exactly-once state semantics within an application. The checkpointing mechanism exposes hooks for application code to include external systems into the checkpointing mechanism as well (like opening and committing transactions with a database system).
Flink also includes a mechanism called savepoints, which are manually-triggered checkpoints.[21] A user can generate a savepoint, stop a running Flink program, then resume the program from the same application state and position in the stream. Savepoints enable updates to a Flink program or a Flink cluster without losing the application's state . As of Flink 1.2, savepoints also allow to restart an application with a different parallelism—allowing users to adapt to changing workloads.
DataStream API
[edit]Flink's DataStream API enables transformations (e.g. filters, aggregations, window functions) on bounded or unbounded streams of data. The DataStream API includes more than 20 different types of transformations and is available in Java and Scala.[22]
A simple example of a stateful stream processing program is an application that emits a word count from a continuous input stream and groups the data in 5-second windows:
import org.apache.flink.streaming.api.scala._
import org.apache.flink.streaming.api.windowing.time.Time
case class WordCount(word: String, count: Int)
object WindowWordCount {
def main(args: Array[String]) {
val env = StreamExecutionEnvironment.getExecutionEnvironment
val text = env.socketTextStream("localhost", 9999)
val counts = text.flatMap { _.toLowerCase.split("\\W+") filter { _.nonEmpty } }
.map { WordCount(_, 1) }
.keyBy("word")
.timeWindow(Time.seconds(5))
.sum("count")
counts.print
env.execute("Window Stream WordCount")
}
}
Apache Beam - Flink Runner
[edit]Apache Beam “provides an advanced unified programming model, allowing (a developer) to implement batch and streaming data processing jobs that can run on any execution engine.”[23] The Apache Flink-on-Beam runner is the most feature-rich according to a capability matrix maintained by the Beam community.[24]
data Artisans, in conjunction with the Apache Flink community, worked closely with the Beam community to develop a Flink runner.[25]
DataSet API
[edit]Flink's DataSet API enables transformations (e.g., filters, mapping, joining, grouping) on bounded datasets. The DataSet API includes more than 20 different types of transformations.[26] The API is available in Java, Scala and an experimental Python API. Flink's DataSet API is conceptually similar to the DataStream API. This API is deprecated at Flink version 2.0 [27]
Table API and SQL
[edit]Flink's Table API is a SQL-like expression language for relational stream and batch processing that can be embedded in Flink's Java and Scala DataSet and DataStream APIs. The Table API and SQL interface operate on a relational Table abstraction. Tables can be created from external data sources or from existing DataStreams and DataSets. The Table API supports relational operators such as selection, aggregation, and joins on Tables.
Tables can also be queried with regular SQL. The Table API and SQL offer equivalent functionality and can be mixed in the same program. When a Table is converted back into a DataSet or DataStream, the logical plan, which was defined by relational operators and SQL queries, is optimized using Apache Calcite and is transformed into a DataSet or DataStream program.[28]
Flink Forward
[edit]Flink Forward is an annual conference about Apache Flink. The first edition of Flink Forward took place in 2015 in Berlin. The two-day conference had over 250 attendees from 16 countries. Sessions were organized in two tracks with over 30 technical presentations from Flink developers and one additional track with hands-on Flink training.
In 2016, 350 participants joined the conference and over 40 speakers presented technical talks in 3 parallel tracks. On the third day, attendees were invited to participate in hands-on training sessions.
In 2017, the event expanded to San Francisco, as well. The conference day was dedicated to technical talks on how Flink is used in the enterprise, Flink system internals, ecosystem integrations with Flink, and the future of the platform. It featured keynotes, talks from Flink users in industry and academia, and hands-on training sessions on Apache Flink.
In 2020, following the COVID-19 pandemic, Flink Forward's spring edition which was supposed to be hosted in San Francisco was canceled. Instead, the conference was hosted virtually, starting on April 22 and concluding on April 24, featuring live keynotes, Flink use cases, Apache Flink internals, and other topics on stream processing and real-time analytics.[29]
In 2024 Flink Forward [30] returned to Berlin, its birth place, for the 10th anniversary. The conference highlighted the new Flink 2.0 plans, where Java 8 is dropped and a new state backend is introduced. Flink CDC [31] was also introduced, allowing no code yaml authored flows. There was also a session on Flink's adoption of OpenLineage.[32]
History
[edit]In 2010, the research project "Stratosphere: Information Management on the Cloud"[33] led by Volker Markl (funded by the German Research Foundation (DFG))[34] was started as a collaboration of Technische Universität Berlin, Humboldt-Universität zu Berlin, and Hasso-Plattner-Institut Potsdam. Flink started from a fork of Stratosphere's distributed execution engine and it became an Apache Incubator project in March 2014.[35] In December 2014, Flink was accepted as an Apache top-level project.[36][37][38][39]
| Version | Original release date | Latest version | Release date | |
|---|---|---|---|---|
| 0.9 | 2015-06-24 | 0.9.1 | 2015-09-01 | |
| 0.10 | 2015-11-16 | 0.10.2 | 2016-02-11 | |
| 1.0 | 2016-03-08 | 1.0.3 | 2016-05-11 | |
| 1.1 | 2016-08-08 | 1.1.5 | 2017-03-22 | |
| 1.2 | 2017-02-06 | 1.2.1 | 2017-04-26 | |
| 1.3 | 2017-06-01 | 1.3.3 | 2018-03-15 | |
| 1.4 | 2017-12-12 | 1.4.2 | 2018-03-08 | |
| 1.5 | 2018-05-25 | 1.5.6 | 2018-12-26 | |
| 1.6 | 2018-08-08 | 1.6.3 | 2018-12-22 | |
| 1.7 | 2018-11-30 | 1.7.2 | 2019-02-15 | |
| 1.8 | 2019-04-09 | 1.8.3 | 2019-12-11 | |
| 1.9 | 2019-08-22 | 1.9.2 | 2020-01-30 | |
| 1.10 | 2020-02-11 | 1.10.3 | 2021-01-29 | |
| 1.11 | 2020-07-06 | 1.11.6 | 2021-12-16 | |
| 1.12 | 2020-12-10 | 1.12.7 | 2021-12-16 | |
| 1.13 | 2021-05-03 | 1.13.6 | 2022-02-18 | |
| 1.14 | 2021-09-29 | 1.14.6 | 2022-09-28 | |
| 1.15 | 2022-05-05 | 1.15.4 | 2023-03-15 | |
| 1.16 | 2022-10-28 | 1.16.3 | 2023-11-29 | |
| 1.17 | 2023-03-23 | 1.17.2 | 2023-11-29 | |
| 1.18 | 2023-10-24 | 1.18.1 | 2024-01-19 | |
| 1.19 | 2024-03-18 | 1.19.2 | 2025-02-12 | |
| 1.20 (LTS) | 2024-08-02 | 1.20.1 | 2025-02-12 | |
| 2.0 | 2025-03-19 | 2.0.0 | 2025-03-19 | |
Legend: Unsupported Supported Latest version | ||||
Release Dates
- 03/2025: Apache Flink 2.0 (03/2025: v2.0.0)
- 08/2024: Apache Flink 1.20 (02/2025: v1.20.1)
- 03/2024: Apache Flink 1.19 (06/2024: v1.19.1, 02/2025: v1.19.2)
- 10/2023: Apache Flink 1.18 (01/2024: v1.18.1)
- 03/2023: Apache Flink 1.17 (05/2023: v1.17.1; 11/2023: v1.17.2)
- 10/2022: Apache Flink 1.16 (01/2023: v1.16.1; 05/2023: v1.16.2; 11/2023: v1.16.3)
- 05/2022: Apache Flink 1.15 (07/2022: v1.15.1; 08/2022: v1.15.2; 11/2022: v1.15.3; 03/2023: v1.15.4)
- 09/2021: Apache Flink 1.14 (12/2021: v1.14.2; 01/2022: v1.14.3; 03/2022: v1.14.4; 06/2022: v1.14.5; 09/2022: v1.14.6)
- 05/2021: Apache Flink 1.13 (05/2021: v1.13.1; 08/2021: v1.13.2; 10/2021: v1.13.3; 12/2021: v1.13.5; 02/2022: v1.13.6)
- 12/2020: Apache Flink 1.12 (01/2021: v1.12.1; 03/2021: v1.12.2; 04/2021: v1.12.3; 05/2021: v1.12.4; 08/2021: v1.12.5; 12/2021: v1.12.7)
- 07/2020: Apache Flink 1.11 (07/2020: v1.11.1; 09/2020: v1.11.2; 12/2020: v1.11.3; 08/2021: v1.11.4; 12/2021: v1.11.6)
- 02/2020: Apache Flink 1.10 (05/2020: v1.10.1; 08/2020: v1.10.2; 01/2021: v1.10.3)
- 08/2019: Apache Flink 1.9 (10/2019: v1.9.1; 01/2020: v1.9.2)
- 04/2019: Apache Flink 1.8 (07/2019: v1.8.1; 09/2019: v1.8.2; 12/2019: v1.8.3)
- 11/2018: Apache Flink 1.7 (12/2018: v1.7.1; 02/2019: v1.7.2)
- 08/2018: Apache Flink 1.6 (09/2018: v1.6.1; 10/2018: v1.6.2; 12/2018: v1.6.3; 02/2019: v1.6.4)
- 05/2018: Apache Flink 1.5 (07/2018: v1.5.1; 07/2018: v1.5.2; 08/2018: v1.5.3; 09/2018: v1.5.4; 10/2018: v1.5.5; 12/2018: v1.5.6)
- 12/2017: Apache Flink 1.4 (02/2018: v1.4.1; 03/2018: v1.4.2)
- 06/2017: Apache Flink 1.3 (06/2017: v1.3.1; 08/2017: v1.3.2; 03/2018: v1.3.3)
- 02/2017: Apache Flink 1.2 (04/2017: v1.2.1)
- 08/2016: Apache Flink 1.1 (08/2016: v1.1.1; 09/2016: v1.1.2; 10/2016: v1.1.3; 12/2016: v1.1.4; 03/2017: v1.1.5)
- 03/2016: Apache Flink 1.0 (04/2016: v1.0.1; 04/2016: v1.0.2; 05/2016: v1.0.3)
- 11/2015: Apache Flink 0.10 (11/2015: v0.10.1; 02/2016: v0.10.2)
- 06/2015: Apache Flink 0.9 (09/2015: v0.9.1)
- 04/2015: Apache Flink 0.9-milestone-1
Apache Incubator Release Dates
- 01/2015: Apache Flink 0.8-incubating
- 11/2014: Apache Flink 0.7-incubating
- 08/2014: Apache Flink 0.6-incubating (09/2014: v0.6.1-incubating)
- 05/2014: Stratosphere 0.5 (06/2014: v0.5.1; 07/2014: v0.5.2)
Pre-Apache Stratosphere Release Dates
- 01/2014: Stratosphere 0.4 (version 0.3 was skipped)
- 08/2012: Stratosphere 0.2
- 05/2011: Stratosphere 0.1 (08/2011: v0.1.1)
The 1.14.1, 1.13.4, 1.12.6, 1.11.5 releases, which were supposed to only contain a Log4j upgrade to 2.15.0, were skipped because CVE-2021-45046 was discovered during the release publication.[40]
See also
[edit]References
[edit]- ^ "Release 2.1.1". 30 October 2025. Retrieved 11 November 2025.
- ^ "All stable Flink releases". flink.apache.org. Apache Software Foundation. Retrieved 2021-12-20.
- ^ "Apache Flink: Scalable Batch and Stream Data Processing". apache.org.
- ^ "apache/flink". GitHub. 29 January 2022.
- ^ Alexander Alexandrov, Rico Bergmann, Stephan Ewen, Johann-Christoph Freytag, Fabian Hueske, Arvid Heise, Odej Kao, Marcus Leich, Ulf Leser, Volker Markl, Felix Naumann, Mathias Peters, Astrid Rheinländer, Matthias J. Sax, Sebastian Schelter, Mareike Höger, Kostas Tzoumas, and Daniel Warneke. 2014. The Stratosphere platform for big data analytics. The VLDB Journal 23, 6 (December 2014), 939-964. DOI
- ^ Ian Pointer (7 May 2015). "Apache Flink: New Hadoop contender squares off against Spark". InfoWorld.
- ^ "On Apache Flink. Interview with Volker Markl". odbms.org.
- ^ Stephan Ewen, Kostas Tzoumas, Moritz Kaufmann, and Volker Markl. 2012. Spinning fast iterative data flows. Proc. VLDB Endow. 5, 11 (July 2012), 1268-1279. DOI
- ^ "Benchmarking Streaming Computation Engines at Yahoo!". Yahoo Engineering. Retrieved 2017-02-23.
- ^ a b Carbone, Paris; Fóra, Gyula; Ewen, Stephan; Haridi, Seif; Tzoumas, Kostas (2015-06-29). "Lightweight Asynchronous Snapshots for Distributed Dataflows". arXiv:1506.08603 [cs.DC].
- ^ "Apache Flink 1.2.0 Documentation: Python Programming Guide". ci.apache.org. Retrieved 2017-02-23.
- ^ "Apache Flink 1.2.0 Documentation: Table and SQL". ci.apache.org. Retrieved 2017-02-23.
- ^ Fabian Hueske, Mathias Peters, Matthias J. Sax, Astrid Rheinländer, Rico Bergmann, Aljoscha Krettek, and Kostas Tzoumas. 2012. Opening the black boxes in data flow optimization. Proc. VLDB Endow. 5, 11 (July 2012), 1256-1267. DOI
- ^ Daniel Warneke and Odej Kao. 2009. Nephele: efficient parallel data processing in the cloud. In Proceedings of the 2nd Workshop on Many-Task Computing on Grids and Supercomputers (MTAGS '09). ACM, New York, NY, USA, Article 8, 10 pages. DOI
- ^ a b "Apache Flink 1.2.0 Documentation: Streaming Connectors". ci.apache.org. Retrieved 2017-02-23.
- ^ "ASF Git Repos - flink.git/blob - LICENSE". apache.org. Archived from the original on 2017-10-23. Retrieved 2015-04-12.
- ^ "Apache Flink Committee Information". Retrieved 2025-04-10.
- ^ a b "Apache Flink 1.2.0 Documentation: Dataflow Programming Model". ci.apache.org. Retrieved 2017-02-23.
- ^ "Kinesis Data Streams: processing streaming data in real time". 5 January 2022.
- ^ "Apache Flink 1.2.0 Documentation: Distributed Runtime Environment". ci.apache.org. Retrieved 2017-02-24.
- ^ "Apache Flink 1.2.0 Documentation: Distributed Runtime Environment - Savepoints". ci.apache.org. Retrieved 2017-02-24.
- ^ "Apache Flink 1.2.0 Documentation: Flink DataStream API Programming Guide". ci.apache.org. Retrieved 2017-02-24.
- ^ "Apache Beam". beam.apache.org. Retrieved 2017-02-24.
- ^ "Apache Beam Capability Matrix". beam.apache.org. Retrieved 2017-02-24.
- ^ "Why Apache Beam? A Google Perspective | Google Cloud Big Data and Machine Learning Blog | Google Cloud Platform". Google Cloud Platform. Archived from the original on 2017-02-25. Retrieved 2017-02-24.
- ^ "Apache Flink 1.2.0 Documentation: Flink DataSet API Programming Guide". ci.apache.org. Retrieved 2017-02-24.
- ^ "Deprecated Flink version 2.0 APIs". Retrieved 2025-04-10.
- ^ "Stream Processing for Everyone with SQL and Apache Flink". flink.apache.org. 24 May 2016. Retrieved 2020-01-08.
- ^ "Flink Forward Virtual Conference 2020".
- ^ "Flink Forward". Retrieved 9 April 2025.
- ^ "Change Data Capture". Retrieved 9 April 2025.
- ^ "OpenLineage". Retrieved 9 April 2025.
- ^ "Stratosphere". stratosphere.eu.
- ^ "Stratosphere - Information Management on the Cloud". Deutsche Forschungsgemeinschaft (DFG). Retrieved 2023-12-01.
- ^ "Stratosphere". apache.org.
- ^ "Project Details for Apache Flink". apache.org.
- ^ "The Apache Software Foundation Announces Apache™ Flink™ as a Top-Level Project : The Apache Software Foundation Blog". apache.org. 12 January 2015.
- ^ "Will the mysterious Apache Flink find a sweet spot in the enterprise?". siliconangle.com. 9 February 2015.
- ^ (in German)
- ^ "Apache Flink Log4j emergency releases". flink.apache.org. Apache Software Foundation. 16 December 2021. Retrieved 2021-12-22.
External links
[edit]Apache Flink
View on GrokipediaIntroduction
Overview
Apache Flink is an open-source, distributed processing engine designed for stateful computations over unbounded and bounded data streams.[1] It provides a unified architecture that treats batch processing as a special case of streaming, allowing developers to build applications that handle both real-time and historical data with the same codebase and runtime. This stream-first design enables low-latency, high-throughput processing suitable for modern data-intensive applications.[1] At its core, Flink adheres to principles such as end-to-end exactly-once semantics. Flink achieves end-to-end exactly-once through its checkpointing mechanism combined with TwoPhaseCommitSinkFunction, which implements two-phase commit for sinks supporting transactions (e.g., Apache Kafka transactional producers). This ensures atomic commits across sources, state, and sinks. When using Kafka as both source and sink, Flink leverages Kafka transactions for robust guarantees. Similar integrations exist for other transactional systems such as Apache Pulsar.[9] It scales horizontally to thousands of cores, managing very large state through features like incremental checkpoints.[10] Additionally, Flink supports event-time processing, which aligns computations with the timestamps of events rather than processing time, enabling accurate handling of out-of-order data.[1] In comparison to predecessors like Hadoop MapReduce, which relies on disk-based batch processing and lacks native streaming support, Flink offers in-memory computation and true streaming capabilities for faster, more efficient real-time analytics. Relative to contemporaries like Apache Spark, Flink's stream-native architecture provides lower latency and better state management for continuous data flows, though Spark remains dominant for batch-heavy workloads.[11] Flink has seen widespread adoption for real-time analytics by companies including Alibaba, Netflix, and Uber.[12]Key Features
Apache Flink provides exactly-once processing guarantees, ensuring that each input event is processed precisely once even in the presence of failures, through its checkpointing mechanism that captures consistent snapshots of application state.[10] Savepoints extend this capability by allowing manual, consistent snapshots for application upgrades, scaling, or migration without data loss.[13] Flink natively supports both event-time and processing-time semantics for streaming data, enabling accurate handling of out-of-order events based on their occurrence timestamps rather than arrival times, which is essential for reliable analytics in real-world scenarios like sensor data or financial transactions.[10] The framework offers flexible windowing mechanisms, including tumbling windows for non-overlapping fixed-size intervals, sliding windows for overlapping periods with specified slide durations, and session windows for dynamic grouping based on inactivity gaps.[14] These can be customized with triggers to control evaluation timing and evictors to remove elements before computation, allowing tailored aggregation over unbounded streams.[14] Flink integrates machine learning through the FlinkML library, which enables scalable implementations of algorithms such as alternating least squares for matrix factorization in recommendation systems.[15][16] The Complex Event Processing (CEP) library supports pattern detection in event streams, allowing users to define sequences of events with conditions and temporal constraints for applications like fraud detection or monitoring.[17] In terms of performance, Flink achieves sub-second latencies for real-time processing, as demonstrated in benchmarks like Nexmark, while supporting horizontal scalability across clusters to handle terabyte-scale state.[6][18] It also features built-in backpressure handling to prevent overload by dynamically adjusting data flow rates between operators.[19]Architecture
Distributed Runtime
Apache Flink's distributed runtime forms the core execution engine that enables scalable processing of streaming and batch data across clusters of machines. It orchestrates the deployment and execution of user-defined jobs by transforming high-level application logic into a distributed dataflow graph, which is then optimized and executed in a fault-tolerant manner. The runtime supports both bounded and unbounded data processing, ensuring low-latency and high-throughput performance through efficient resource utilization and data locality.[20] The runtime is composed of two primary process types: the JobManager and TaskManagers. The JobManager serves as the central coordinator, responsible for scheduling tasks, managing resources, and overseeing job execution. It includes subcomponents such as the ResourceManager for allocating slots and containers, the Dispatcher for handling job submissions via REST or Web UI, and the JobMaster for managing individual JobGraphs by translating them into execution plans and distributing tasks. In high-availability setups, multiple JobManagers operate with one active leader and others in standby mode to ensure continuous operation. TaskManagers, on the other hand, execute the actual dataflow tasks assigned by the JobManager. Each TaskManager runs one or more task slots, which are fixed-size resource units that isolate tasks and manage their memory allocation, buffering input/output streams and exchanging data between subtasks.[20] Flink's pipeline execution model optimizes the dataflow graph through techniques like operator chaining and fusion to minimize overhead and latency. Upon job submission, the JobManager generates an execution graph from the logical JobGraph by applying optimizations such as fusing compatible operators (e.g., consecutive map or filter operations) into single tasks. This chaining allows multiple operators to run in the same thread on a TaskManager, reducing serialization, deserialization, and network shuffling costs while improving data locality. Chaining is enabled by default but can be controlled programmatically—for instance, usingstartNewChain() to break chains at specific points or disableChaining() for individual operators—to balance performance and debugging needs.[21]
Deployment of Flink jobs occurs in various modes to support different environments and resource managers. In standalone mode, Flink runs directly on a cluster of machines without an external orchestrator, where the user starts the JobManager and TaskManagers manually or via scripts for simple, on-premises setups. For Hadoop ecosystems, YARN mode integrates with YARN's ResourceManager, allowing dynamic allocation of containers for JobManager and TaskManagers upon job submission. Kubernetes mode deploys Flink as containerized applications, leveraging Kubernetes for pod orchestration, scaling, and service discovery, which is ideal for cloud-native infrastructures. Additionally, cloud-native options from providers like Amazon EMR or Alibaba Cloud Realtime Compute offer managed deployments that handle infrastructure provisioning and integration with cloud services. In all modes, a client submits the JobGraph to the JobManager, which then provisions TaskManagers as needed for execution.[22]
Resource allocation in the runtime relies on a slot-based model to control parallelism and scaling. Each TaskManager exposes configurable task slots, the smallest allocatable unit, where each slot dedicates a portion of the TaskManager's resources (primarily memory) to one or more subtasks, enabling concurrent execution. Parallelism is set at the job or operator level, with slots shared across pipelines by default to maximize utilization; for example, a single slot can handle multiple chained operators from the same pipeline. Dynamic scaling is facilitated by the Adaptive Scheduler, which adjusts job parallelism reactively based on available slots—scaling up by adding TaskManagers or down by reducing parallelism using savepoints—without interrupting execution. This is particularly useful in elastic environments like Kubernetes, where resources can be redeclared at runtime via APIs to respond to workload variations.[20][23]
To handle varying data rates and prevent job failures from overload, Flink implements a credit-based backpressure mechanism at the task level. When a downstream task cannot consume data as quickly as an upstream task produces it—due to bottlenecks like slow sinks or complex computations—the upstream task experiences backpressure through depleted output buffers. This triggers a flow control signal that propagates upstream, slowing input rates (e.g., throttling sources) without dropping records or crashing the job. Buffering in TaskManagers absorbs temporary spikes, while metrics such as backPressuredTimeMsPerSecond (tracking time spent waiting on buffers) allow monitoring and diagnosis, with status levels from OK (under 10% backpressure) to HIGH (over 50%). This ensures stable execution even under imbalanced loads.[24]
State Management and Fault Tolerance
Apache Flink's state management enables the persistence and consistent handling of application state across distributed tasks, crucial for maintaining computational progress in long-running stream processing jobs. State in Flink represents the data maintained by operators, such as accumulators in window functions or key-value mappings in keyed streams, and is stored locally on TaskManagers unless configured otherwise. This local storage facilitates fast access during normal operation, while fault tolerance mechanisms ensure state recovery upon failures without data loss or duplication. Flink provides several state backends to manage how state is stored and checkpointed, balancing performance, scalability, and persistence needs. The HeapStateBackend (also known as HashMapStateBackend) stores state as objects directly in the Java heap memory of TaskManagers, offering high-speed access suitable for applications with moderate state sizes or when high availability is ensured through replication. However, it is limited by available memory and does not persist state to disk by default, making it vulnerable to TaskManager failures without checkpoints. In contrast, the RocksDBStateBackend (EmbeddedRocksDBStateBackend) serializes state into RocksDB, a key-value store embedded in each TaskManager, writing data to local disk directories for persistence. This backend excels in handling very large states—potentially terabytes—by spilling to disk when memory is constrained, though it incurs overhead from serialization and I/O operations. For global state storage, Flink supports filesystem options, where checkpoints are written to remote durable storage like HDFS or S3; the experimental ForStStateBackend further enables disaggregated state by storing it asynchronously on remote filesystems, allowing unlimited state sizes and decoupling from local TaskManager resources. The choice of backend impacts checkpointing efficiency and recovery times, with RocksDB and ForSt supporting incremental updates to minimize data transfer.[25] Checkpoints form the core of Flink's fault tolerance, capturing periodic, consistent snapshots of the entire application state and input stream positions to enable recovery as if no failure occurred. Enabled via configuration (e.g.,env.enableCheckpointing(1000) for one-second intervals), checkpoints use a snapshot-and-restore mechanism where the JobManager coordinates the process across all tasks. This involves streaming barriers—special markers injected into data streams—that trigger state serialization without halting processing, ensuring a globally consistent view. The protocol employs a two-phase commit approach: in the first phase, tasks write state snapshots to durable storage and acknowledge; in the second phase, upon all acknowledgments, the JobManager finalizes the checkpoint, guaranteeing atomicity. This design supports exactly-once semantics internally by pre-aggregating state changes before barriers and replaying from the last checkpoint upon failure, restoring operators to their exact prior state.[26]
For end-to-end consistency with external systems, Flink extends exactly-once guarantees through transactional integrations, such as with Apache Kafka via idempotent producers or two-phase commit sinks that coordinate with external transaction managers. For instance, when Kafka serves as both source and sink, Flink's checkpoint-aligned offsets ensure that upon recovery, messages are neither skipped nor duplicated across the pipeline. These guarantees hold for stateful operators, where pre-aggregated results (e.g., window sums) are committed only after barrier alignment, preventing partial updates.
Savepoints build on checkpoints as manually triggered, portable snapshots that allow pausing, resuming, or migrating jobs across clusters or versions. Unlike automatic checkpoints, savepoints are initiated via commands (e.g., flink savepoint <job-id> <path>), storing state in a version-agnostic format compatible with future Flink releases, facilitating upgrades without downtime. They are stored in configurable directories on durable filesystems, enabling blueprinting of production jobs for development or scaling.
To optimize for large-state applications, Flink supports incremental checkpoints, which capture only changes (deltas) since the previous checkpoint rather than full snapshots. Enabled by setting execution.checkpointing.incremental: true, this feature—available in RocksDB and ForSt backends—significantly reduces checkpointing time and storage overhead; for example, in scenarios with gigabytes of state, incremental mode can cut completion times from hours to minutes by avoiding redundant serialization of unchanged data. The backend maintains versioned logs of modifications, merging them periodically to bound storage growth. This efficiency is vital for real-time applications processing high-volume streams, ensuring fault tolerance without compromising latency.[27]
Programming Model
DataStream API
The DataStream API serves as the foundational programming interface in Apache Flink for developing scalable stream and batch processing applications, enabling developers to ingest, transform, and output continuous or finite data streams in a distributed environment.[28] It supports both unbounded streams, which represent potentially infinite data flows like real-time sensor inputs, and bounded streams for finite datasets, allowing unified processing logic across streaming and batch workloads.[28] This API is implemented in Java and Python, with transformations applied lazily to form a directed acyclic graph (DAG) that Flink's runtime optimizes and executes. In Flink 2.0, an experimental DataStream API V2 was introduced to enhance the original API with improved ergonomics and performance.[29] At its core, the DataStream abstraction encapsulates immutable collections of elements of the same type, sourced from external systems and manipulated through a rich set of operators.[28] A DataStream can be created from various inputs, such as files or message queues, and undergoes transformations that produce new DataStreams without altering the original.[28] Key transformations includemap, which applies a one-to-one function to each element—for instance, converting a string to an integer via input.map(value -> Integer.parseInt(value))[30]—and filter, which selectively retains elements based on a predicate, such as excluding zero values with data.filter(value -> value != 0).[30] For aggregation, keyBy logically partitions the stream by a key selector, enabling keyed stateful operations like reduce, which iteratively combines elements within a key group, e.g., summing integers through keyedStream.reduce((a, b) -> a + b).[30]
Flink's handling of time is crucial for accurate stream processing, distinguishing between processing time, which relies on the system's clock during computation and is sensitive to delays; ingestion time, assigned when data arrives at the source operator; and event time, derived from timestamps embedded in the data records themselves to reflect real-world occurrence order.[31] Event time is preferred for out-of-order arrivals common in distributed systems, managed via watermarks—special records that indicate the latest observed event time and bound lateness, allowing Flink to close windows and discard excessively delayed elements.[31] Developers assign timestamps and watermarks using the TimestampAssigner and WatermarkGenerator interfaces, often with strategies like bounded-out-of-orderness to tolerate minor delays.[31]
Windowing in the DataStream API groups unbounded streams into finite subsets for aggregation, supporting count-based windows that trigger after a fixed number of elements, such as every 100 tuples, and time-based windows aligned to event, ingestion, or processing time.[32] Common types include tumbling windows for non-overlapping intervals (e.g., 5-minute slots via TumblingEventTimeWindows.of(Time.minutes(5))) and sliding windows that overlap by a specified duration.[32] Applied on keyed streams, windows use functions like reduce for incremental updates or aggregate for custom logic, such as computing averages with a user-defined aggregator.[32] Late data, arriving after a watermark passes a window's end, can be handled by allowing configurable lateness or redirecting to side outputs, ensuring robustness in asynchronous environments.[32]
For advanced patterns, side outputs enable operators to emit secondary streams of data that do not fit the primary result type, such as tagging anomalous events with OutputTag for separate processing.[33] Broadcasting complements this by distributing a control stream to all parallel instances of a downstream operator, facilitating dynamic rule updates in keyed computations without full repartitioning.[30] These mechanisms support complex, stateful applications while integrating with Flink's fault-tolerant state backend for consistency.[33]
DataStream applications connect to external systems via connectors for sources and sinks, with built-in support for reading from files (e.g., using FileSource for continuous monitoring) or sockets, and writing to similar targets.[34] Third-party connectors, such as those for Apache Kafka, allow scalable ingestion from topics using KafkaSource and output via KafkaSink, configured with serialization schemas for seamless integration into event-driven architectures.[35]
Table API and SQL
The Table API and SQL in Apache Flink provide declarative interfaces for relational data processing, enabling unified handling of both streaming and batch data through a high-level abstraction over the underlying DataStream API.[36] These APIs allow users to express queries using familiar relational concepts, such as tables and joins, while leveraging Flink's distributed runtime for scalable execution. The Table API offers a fluent, expression-based approach in languages like Java, Scala, and Python, whereas SQL provides a standardized query language for more direct declarative programming. Both integrate seamlessly to support complex analytics workloads, from real-time aggregations to historical batch computations.[36] The Table API is a language-integrated query builder that enables the creation of tables from input streams or batches using methods likeTableEnvironment.from(), which converts DataStream objects into relational tables without altering the underlying data flow.[37] It supports a range of relational operations, including selections for projecting and computing fields, joins for combining tables based on conditions, and groupBy for aggregations over grouped data. For instance, in Java, a simple aggregation might be expressed as orders.groupBy($("category")).select($("category"), $("price").avg().as("avgPrice")), where $ denotes column references, demonstrating the API's concise syntax with IDE-friendly autocompletion and type safety.[37] This fluent style abstracts away low-level stream manipulations, focusing on relational logic while maintaining unified semantics for bounded (batch) and unbounded (streaming) inputs.[37]
Flink's SQL integration, built on Apache Calcite, offers compliance with ANSI SQL:2011 standards, supporting core Data Definition Language (DDL) for creating tables and views, Data Manipulation Language (DML) for inserts and updates, and standard query constructs like SELECT for filtering and projecting data.[38] It extends SQL for streaming scenarios through dynamic tables, which represent changing data sources as append-only or updatable streams, allowing queries to produce continuously updating results.[39] Temporal joins further enhance streaming capabilities by correlating rows based on event time or processing time against versioned tables, such as enriching transaction data with historical exchange rates at specific timestamps via syntax like SELECT * FROM transactions AS t JOIN rates FOR SYSTEM_TIME AS OF t.proctime AS r ON t.currency = r.currency.[40] These features enable expressive queries over time-sensitive data without manual state management.
Catalog management in Flink unifies metadata handling across Table API and SQL, providing a persistent namespace for databases, tables, functions, and views.[41] The Hive Catalog integrates with Apache Hive Metastore for storing Flink metadata alongside existing Hive tables, supporting case-insensitive operations and seamless access to Hive-compatible data warehouses via configurations like HiveCatalog hive = new HiveCatalog("myhive", "thrift://hive-metastore:9083", "default").[42] Similarly, the JDBC Catalog connects to relational databases such as PostgreSQL or MySQL, automatically mapping schemas and enabling DDL operations like CREATE TABLE to propagate metadata changes. This abstraction allows users to reference external metadata sources directly in queries, facilitating hybrid stream-batch environments.
Continuous queries in Flink transform batch processing into streaming by treating finite datasets as changelog streams, where operations like aggregations produce ongoing updates maintained as materialized views.[39] For example, a windowed aggregation over batch input can be expressed as a continuous query using TUMBLE functions in SQL, yielding incremental results that evolve with new data appends, thus bridging traditional batch jobs with real-time requirements through eager view maintenance.[39]
Flink's query optimizer, powered by Apache Calcite, combines rule-based rewrites—such as subquery decorrelation, filter push-down, and join reordering—with cost-based optimization that evaluates execution plans using statistics on data volume, cardinality, and resource costs like CPU and I/O.[43] This dual approach ensures efficient plans; for instance, rule-based pruning eliminates unnecessary projections early, while cost-based decisions select optimal join strategies based on table sizes, configurable via options like table.optimizer.join-reorder-enabled=true.[43] The optimizer applies these transformations transparently, enhancing performance for both simple filters and complex multi-table queries without user intervention.[43]
Batch and Extension APIs
The DataSet API, Flink's legacy imperative interface for batch processing, was removed in Apache Flink 2.0 (released March 2025).[6] Batch workloads are now handled through the unified DataStream API in batch execution mode or the Table API and SQL.[44] Since Flink 1.12, the DataSet API had been marked as legacy and soft-deprecated, with official deprecation in version 1.18, as the framework unifies stream and batch processing under the DataStream API and Table API/SQL.[45][46] It was removed in Flink 2.0, and users are encouraged to use the unified APIs for batch workloads.[6] The Apache Beam Flink Runner enables the execution of portable Beam pipelines on the Flink runtime, translating Beam'sPTransforms and DoFns into Flink jobs for both streaming and batch processing.[47] Available in classic (Java-only) and portable (supporting Java, Python, Go) flavors, it leverages Flink's capabilities for high-throughput, low-latency execution with exactly-once semantics, deployable on clusters like YARN or Kubernetes.[47] For batch scenarios, it processes bounded inputs efficiently, with capabilities detailed in Beam's runner matrices.[48]
FlinkML extends Flink for machine learning pipelines, offering Table API-based components like Estimator for training models on batch datasets and Transformer for feature engineering and predictions.[49] It supports batch workflows, such as fitting models on tabular data via methods like fit(), and includes algorithms for tasks like clustering and regression.[49] Similarly, the Complex Event Processing (CEP) library detects patterns in event sequences using a declarative Pattern API, applicable to batch data when executed via the DataStream API in batch mode for finite datasets.[50]
Migration from the DataSet API to unified APIs involves replacing ExecutionEnvironment with StreamExecutionEnvironment set to BATCH mode for DataStream equivalents, or adopting the Table API/SQL for relational batch queries.[51] Direct mappings exist for transformations like map and filter, while operations like join may require windowing adjustments; connectors for sources and sinks remain compatible with minimal changes.[51] For Table API migrations, users convert datasets to tables using as() methods and express logic declaratively, ensuring semantic equivalence for batch processing.[51]
History
Origins and Early Development
The Stratosphere project originated in 2009 as a collaborative research initiative led by the Technical University of Berlin (TU Berlin) and Humboldt University of Berlin, with the goal of advancing distributed data processing systems for large-scale analytics.[4] Funded initially by the German Research Foundation (DFG), the effort brought together academic researchers to explore innovative architectures beyond existing paradigms.[52] Key contributors included Stephan Ewen and Kostas Tzoumas, who served as lead developers from TU Berlin, alongside Volker Markl, Alexander Alexandrov, and others from the involved institutions, with growing involvement from industry partners over time.[53] The core motivation for Stratosphere stemmed from the recognized shortcomings of Apache Hadoop's MapReduce model, which excelled at simple batch jobs but struggled with iterative algorithms essential for machine learning, graph processing, and optimization tasks due to its acyclic execution and repeated data reloading overhead. To overcome these, the project introduced the PACT (Parallelization Contracts) programming model, a generalization of MapReduce that supported higher-order functions and delta iterations for efficient incremental updates in loops. Additionally, Stratosphere emphasized pipelined dataflow execution to enable low-latency processing, laying groundwork for unified handling of both batch and streaming workloads, though initial emphasis was on batch-oriented analytics. Early development progressed with the project's first open-source release, Stratosphere 0.1, in 2011, which centered on batch processing capabilities while incorporating prototype support for streaming through pipelined operators.[54] Subsequent versions built on this foundation, refining the runtime and APIs. In April 2014, the Stratosphere team donated the codebase to the Apache Software Foundation Incubator, renaming it Apache Flink to resolve trademark concerns and align with open-source governance.[55][4] This transition marked the shift from academic prototyping to a broader community-driven project, culminating in Flink's graduation to top-level Apache status in December 2014.[4]Major Releases and Evolution
Apache Flink achieved top-level project status within the Apache Software Foundation in December 2014, marking a significant milestone in its maturation as an open-source framework.[56] This transition from the Apache Incubator enabled greater community governance and resource allocation for development. In March 2016, Flink released version 1.0, which introduced stable APIs with guaranteed backward compatibility across the 1.x series, facilitating reliable production deployments and encouraging wider adoption by ensuring application portability.[5] A pivotal architectural shift occurred with Flink 1.12 in December 2020, which unified batch and stream processing under a single runtime. This release deprecated the legacy DataSet API in favor of the DataStream API in batch mode, simplifying development and operations by eliminating the need for separate batch and streaming pipelines.[57] Subsequent releases built on this foundation with targeted enhancements. Flink 1.18, released in October 2023, improved PyFlink support through better user-defined function (UDF) integration and Python packaging, making it easier for Python developers to build scalable streaming applications.[58] Flink 1.20, announced in August 2024, advanced Change Data Capture (CDC) capabilities with refined Debezium connector support and schema evolution handling, streamlining real-time data synchronization from databases.[59] The transition to the 2.x series accelerated Flink's evolution toward modern infrastructures. Flink 2.0, released on March 24, 2025, introduced AI integrations such as dynamic model invocation in Flink CDC for real-time processing with external AI services like OpenAI, alongside Kubernetes-native features including disaggregated state management on distributed file systems for enhanced scalability in cloud environments.[6] Flink 2.1, launched on July 31, 2025, further upgraded real-time AI capabilities with AI Model DDL for SQL-based model management and realtime AI functions, enabling seamless embedding of machine learning workflows into streaming pipelines.[60] Over these releases, Flink has trended toward cloud-native architectures, exemplified by native Kubernetes integration and elastic scaling optimizations that support terabyte-scale state rescaling without downtime. SQL performance has seen iterative gains, such as adaptive batch execution in 2.0. Ecosystem expansions include Flink CDC 3.4 in May 2025, which added pipeline connectors for targets like Apache Iceberg with batch execution support, broadening integration options for data lakes and warehouses.[61] Subsequent minor releases, including Flink 2.1.1 on November 10, 2025, and Flink CDC 3.5.0 in September 2025, provided bug fixes and additional enhancements.[7][62] These advancements have driven Flink's adoption in real-time AI and streaming ETL scenarios, with surveys indicating faster decision-making through low-latency processing of event data for AI agents and ETL pipelines.[63]Community and Ecosystem
Development Process
Apache Flink operates under the governance of the Apache Software Foundation, with a Project Management Committee (PMC) consisting of 55 members as of August 2025 who oversee the project's direction, release verification, and community decisions. The PMC, established in December 2014, uses consensus-driven processes for major decisions, facilitated by tools such as JIRA for issue tracking and reporting bugs or features.[64] Significant changes and enhancements are proposed and documented through Flink Improvement Proposals (FLIPs), which serve as a centralized mechanism to outline planned major developments while JIRA handles ongoing task tracking and resolution.[65] Contributions to Flink follow structured guidelines to ensure code quality and maintainability, requiring developers to first create a JIRA ticket, discuss the approach on the dev mailing list to reach consensus, and obtain assignment from a committer before submitting pull requests.[66] Adherence to the project's code style is enforced via the Code Style and Quality Guide, with all changes needing to passmvn clean verify builds, including unit and end-to-end tests; unrelated formatting alterations are discouraged to streamline reviews.[66] New contributors are supported through labeled "starter" issues in JIRA, which provide guided entry points for learning the codebase and participating effectively, fostering community involvement without a formal mentorship program.[66]
The project maintains a time-based release cadence of approximately three months for minor versions, enabling regular delivery of features and improvements, while major releases occur roughly annually to introduce significant architectural advancements.[67] Security vulnerabilities and critical bugs receive ad-hoc patch releases on dedicated branches, ensuring timely fixes without disrupting the main development cycle.[67]
Since entering the Apache incubator in 2014, Flink has grown to over 1,300 unique contributors worldwide, reflecting sustained activity and expansion.[68] This includes notable growth in Asia, driven by contributions from organizations like Alibaba, which have enhanced adoption and development in the region through events and code integrations.[69]
Collaboration occurs via mirrored repositories on GitHub for code hosting and pull requests, supplemented by Apache mailing lists for discussions and a dedicated Slack workspace for real-time community interactions.[70]