Apache Flink

求聞百科,共筆求聞
Apache Flink
開發者Apache軟體基金會
首次發布2011年5月,​13年前​(2011-05
程式語言JavaScala
作業系統跨平台
類型
許可協議Apache許可證 2.0

Apache Flink是由Apache軟體基金會開發的開源流處理框架,其核心是用JavaScala編寫的分布式流數據流引擎。[1][2]Flink以數據並行管道方式執行任意流數據程序[3],Flink的流水線運行時系統可以執行批處理和流處理程序。[4][5]此外,Flink的運行時本身也支持迭代算法的執行。[6]

Flink提供高吞吐量、低延遲的流數據引擎[7]以及對事件-時間處理和狀態管理的支持。Flink應用程式在發生機器故障時具有容錯能力,並且支持exactly-once語義。[8]程序可以用Java、Scala[9]Python[10]SQL[11]等語言編寫,並自動編譯和優化[12]到在集群或雲環境中運行的數據流程序。[13]

Flink並不提供自己的數據存儲系統,但為Amazon KinesisApache KafkaAlluxioHDFSApache CassandraElasticsearch等系統提供了數據源和接收器。[14]

開發

Apache Flink是由Apache軟體基金會內的Apache Flink社區基於Apache許可證2.0[15]開發的,該項目已有超過100位代碼提交者和超過460貢獻者。

data Artisans是由Apache Flink的創始人創建的公司。[16]目前,該公司已聘用了12個Apache Flink的代碼提交者。[17]

概述

Apache Flink的數據流編程模型在有限和無限數據集上提供單次事件(event-at-a-time)處理。在基礎層面,Flink程序由流和轉換組成。 「從概念上講,流是一種(可能永無止境的)數據流記錄,轉換是一種將一個或多個流作為輸入並因此產生一個或多個輸出流的操作」。[18]

Apache Flink包括兩個核心API:用於有界或無界數據流的數據流API和用於有界數據集的數據集API。Flink還提供了一個表API,它是一種類似SQL的表達式語言,用於關係流和批處理,可以很容易地嵌入到Flink的數據流和數據集API中。Flink支持的最高級語言是SQL,它在語義上類似於表API,並將程序表示為SQL查詢表達式。

編程模型和分布式運行時

Flink程序在執行後被映射到流數據流,[19]每個Flink數據流以一個或多個源(數據輸入,例如消息隊列或文件系統)開始,並以一個或多個接收器(數據輸出,如消息隊列、文件系統或資料庫等)結束。Flink可以對流執行任意數量的變換,這些流可以被編排為有向無環數據流圖,允許應用程式分支和合併數據流。

Flink提供現成的源和接收連接器,包括Apache Kafka、Amazon Kinesis、HDFSApache Cassandra等。[20]

Flink程序可以作為集群內的分布式系統運行,也可以以獨立模式或在YARN、Mesos、基於Docker的環境和其他資源管理框架下進行部署。[21]

狀態:檢查點、保存點和容錯

Apache Flink具有一種基於分布式檢查點的輕量級容錯機制。[8]檢查點是應用程式狀態和源流中位置的自動異步快照。在發生故障的情況下,啟用了檢查點的Flink程序將在恢復時從上一個完成的檢查點恢復處理,確保Flink在應用程式中保持一次性(exactly-once)狀態語義。檢查點機制暴露應用程式代碼的接口,以便將外部系統包括在檢查點機制中(如打開和提交資料庫系統的事務)。

Flink還包括一種名為保存點的機制,它是一種手動觸發的檢查點。[22]用戶可以生成保存點,停止正在運行的Flink程序,然後從流中的相同應用程式狀態和位置恢復程序。 保存點可以在不丟失應用程式狀態的情況下對Flink程序或Flink群集進行更新。從Flink 1.2開始,保存點還允許以不同的並行性重新啟動應用程式,這使得用戶可以適應不斷變化的工作負載。

數據流API

Flink的數據流API支持有界或無界數據流上的轉換(如過濾器、聚合和窗口函數),包含了20多種不同類型的轉換,可以在Java和Scala中使用。[23]

有狀態流處理程序的一個簡單Scala示例是從連續輸入流發出字數並在5秒窗口中對數據進行分組的應用:

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

Apache Beam「提供了一種高級統一編程模型,允許(開發人員)實現可在在任何執行引擎上運行批處理和流數據處理作業」。[24]Apache Flink-on-Beam運行器是功能最豐富的、由Beam社區維護的能力矩陣。[25]

data Artisans與Apache Flink社區一起,與Beam社區密切合作,開發了一個強大的Flink runner。[26]

數據集API

Flink的數據集API支持對有界數據集進行轉換(如過濾、映射、連接和分組),包含了20多種不同類型的轉換。[27]該API可用於Java、Scala和實驗性的Python API。Flink的數據集API在概念上與數據流API類似。

表API和SQL

Flink的表API是一種類似SQL的表達式語言,用於關係流和批處理,可以嵌入Flink的Java和Scala數據集和數據流API中。表API和SQL接口在關係表抽象上運行,可以從外部數據源或現有數據流和數據集創建表。表API支持關係運算符,如表上的選擇、聚合和連接等。

也可以使用常規SQL查詢表。表API提供了和SQL相同的功能,可以在同一程序中混合使用。將錶轉換回數據集或數據流時,由關係運算符和SQL查詢定義的邏輯計劃將使用Apache Calcite進行優化,並轉換為數據集或數據流程序。

Flink Forward

Flink Forward是一個關於Apache Flink的年度會議。第一屆Flink Forward於2015年在柏林舉行。為期兩天的會議有來自16個國家的250多名與會者。 會議分為兩個部分,Flink開發人員提供30多個技術演示,另外還有一個Flink培訓實踐。

2016年,350名與會者參加了會議,40多位發言人在3個平行軌道上進行了技術講座。第三天,與會者被邀請參加實踐培訓課程。

2017年,該活動也將擴展到舊金山。 會議致力於Flink如何在企業中使用、Flink系統內部、與Flink的生態系統集成以及平台的未來進行技術會談。它包含主題演講Flink用戶在工業和學術界的講座以及關於Apache Flink的實踐培訓課程。

來自以下組織的發言人在Flink Forward會議上發表了演講:阿里巴巴集團AmadeusBouygues Telecom第一資本Cloudera、data Artisans、EMC愛立信Hortonworks華為IBMGoogleMapRMongoDBNetflixNew RelicOtto GroupRed HatResearchGateUberZalando[28][29]

歷史

2010年,研究項目「Stratosphere:雲上的信息管理」[30](由德國研究基金會(DFG)資助[31])由柏林工業大學柏林洪堡大學哈索·普拉特納研究院合作啟動。Flink從Stratosphere的分布式執行引擎的一個分支開始,於2014年3月成為Apache孵化器項目。[32]2014年12月,Flink成為Apache頂級項目。[33][34][35][36]

版本 原始發布的日期 最新版本 發布日期
舊版本,不再支援: 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.5 2018-10-29
舊版本,仍被支援: 1.6 2018-08-08 1.6.2 2018-10-29
當前版本: 1.7 2018-11-30 1.7.2 2019-02-15
格式:
舊版本
舊版本,仍被支援
當前版本
最新的預覽版
未來版本

發布日期

Apache孵化器發布日期

Pre-Apache Stratosphere 發布日期

  • 01/2014: Stratosphere 0.4(0.3版本被跳過)
  • 08/2012: Stratosphere 0.2
  • 05/2011: Stratosphere 0.1(08/2011:0.1.1)

參見

參考文獻

  1. Apache Flink: Scalable Batch and Stream Data Processing. apache.org. [2018-12-17]. 
  2. apache/flink. GitHub. [2018-12-17]. 
  3. 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
  4. Ian Pointer. Apache Flink: New Hadoop contender squares off against Spark. InfoWorld. 2015-05-07 [2018-12-17]. 
  5. On Apache Flink. Interview with Volker Markl.. odbms.org. [2018-12-17]. 
  6. 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
  7. Benchmarking Streaming Computation Engines at Yahoo!. Yahoo Engineering. [2017-02-23]. 
  8. 8.0 8.1 A bot will complete this citation soon. Click here to jump the queue arXiv:[1].
  9. Apache Flink 1.2.0 Documentation: Flink DataStream API Programming Guide. ci.apache.org. [2017-02-23] (英語). 
  10. Apache Flink 1.2.0 Documentation: Python Programming Guide. ci.apache.org. [2017-02-23] (英語). 
  11. Apache Flink 1.2.0 Documentation: Table and SQL. ci.apache.org. [2017-02-23] (英語). 
  12. 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
  13. 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
  14. Apache Flink 1.2.0 Documentation: Streaming Connectors. ci.apache.org. [2017-02-23] (英語). 
  15. ASF Git Repos - flink.git/blob - LICENSE. apache.org. [2018-12-17]. 
  16. Team – data Artisans. data-artisans.com. [2017-02-23] (美國英語). 
  17. Apache Flink: Community & Project Info. flink.apache.org. [2017-02-23] (英語). 
  18. Apache Flink 1.2.0 Documentation: Dataflow Programming Model. ci.apache.org. [2017-02-23] (英語). 
  19. Apache Flink 1.2.0 Documentation: Dataflow Programming Model. ci.apache.org. [2017-02-23] (英語). 
  20. Apache Flink 1.2.0 Documentation: Streaming Connectors. ci.apache.org. [2017-02-23] (英語). 
  21. Apache Flink 1.2.0 Documentation: Distributed Runtime Environment. ci.apache.org. [2017-02-24] (英語). 
  22. Apache Flink 1.2.0 Documentation: Distributed Runtime Environment - Savepoints. ci.apache.org. [2017-02-24] (英語). 
  23. Apache Flink 1.2.0 Documentation: Flink DataStream API Programming Guide. ci.apache.org. [2017-02-24] (英語). 
  24. Apache Beam. beam.apache.org. [2017-02-24] (英語). 
  25. Apache Beam Capability Matrix. beam.apache.org. [2017-02-24] (英語). 
  26. Why Apache Beam? A Google Perspective | Google Cloud Big Data and Machine Learning Blog | Google Cloud Platform. Google Cloud Platform (英語). 
  27. Apache Flink 1.2.0 Documentation: Flink DataSet API Programming Guide. ci.apache.org. [2017-02-24] (英語). 
  28. Sessions | FlinkForward | 12-14 Sep 2016 | Berlin. 2016.flink-forward.org. [2017-02-24] (美國英語). 
  29. Flink Forward » Flink Forward 2015. 2015.flink-forward.org. [2017-02-24] (美國英語). 
  30. Stratosphere. stratosphere.eu. [2018-12-18]. 
  31. DFG - Deutsche Forschungsgemeinschaft -. dfg.de. [2018-12-18]. 
  32. Stratosphere. apache.org. [2018-12-18]. 
  33. Project Details for Apache Flink. apache.org. [2018-12-18]. 
  34. The Apache Software Foundation Announces Apache™ Flink™ as a Top-Level Project : The Apache Software Foundation Blog. apache.org. [2018-12-18]. 
  35. Will the mysterious Apache Flink find a sweet spot in the enterprise?. siliconangle.com. [2018-12-18]. 
  36. Benchmarking Streaming Computation Engines: Storm, Flink and Spark Streaming (PDF). IEEE. May 2016 [2018-12-18].