Flink Forward China 2018 - Flink七武器及应用实践

Flink features Flink七武器 – Flink seven killer features 1. StreamingML 2. StreamingDL 3. Time GeoSpatial 4. CEP SQL 5. Cost-based Optimizer 6. Real-time visualization 7. EdgeCompute: Flink-Lite Flink行业应用场景 - Flink Industry Use Case Flink SQL在线体验 - Online Flink SQL in practice
展开查看详情

1.Flink七武器器及应⽤用实战 Flink killer feature in practice 公司:华为 职位:技术专家 演讲者:时⾦金金魁

2.Flink Forward China 2018 ⽽而在这个AI时代,每⼀一个梦想都更更有机会成为现实,每⼀一位开发者的创新与现实仅有⼀一步之遥。 In this AI era, every dream has a better chance to become a reality, and every developer's innovation and reality are only one step away.

3. 个⼈人简介 Profiles! 华为云⾼高级技术专家,负责实时流计算服务、⽇日志分析服务和⻋车 联⽹网智能体,智慧城市架构师。 12年年的开发经验,2012年年开始研究Spark。多年年来从事⾼高性能计 算和⼤大数据⽅方⾯面的⼯工作,曾参与国内互联⽹网产品开发。近3年年专 注于Flink和Spark的研究和云产品开发。 Huawei Cloud Senior Technical expert, responsible for CloudStream services, log Analysis Services and Vehicle Intelligent Twins, smart city architect. Have 12 years developping experience. 2012 began to study the spark, 2016 began to study the Flink. Over the years engaged in high- performance computing and big data work, has been involved in several Internet product development. Nearly 3 years of research and cloud product development focused on Flink and spark. 3 Huawei Confidential

4. 内容提要 Agent o  Flink features o  Flink七武器器 – Flink seven killer features 1. StreamingML 2. StreamingDL 3. Time GeoSpatial 4. CEP SQL 5. Cost-based Optimizer 6. Real-time visualization 7. EdgeCompute: Flink-Lite o  Flink⾏行行业应⽤用场景 - Flink Industry Use Case o  Flink SQL在线体验 - Online Flink SQL in practice

5.开源流计算框架! Open Source Stream Framework! 实时流计算服务 稳

6. Flink关键特性 Flink key features

7. Flink关键特性:运⾏行行时流图 Flink key features: Runtime of Dataflow 1.  Build DAG 2.  Schedule rresource 3.  Lazy apply function

8.Flink关键特性:⽀支持解决乱序问题 Flink key features: resolve out-of-orderness problem Picture from Apache Flink Flink source generate Watermark,in parallel operators aligning the watermark flow(timestamp) 1.  Fixed latency time:BoundedOutOfOrdernessTimestampExtractor(Time maxOutOfOrderness) 2.  Allowed latency beside fixed latency configure:allowedLateness()

9. Flink关键特性:三种窗⼝口 Flink key features: three windows 1.  Tumbling window 2.  Sliding window 3.  Session window Silding window will cost several times memory. How to save memeory as soon as possible? Dataflow Model: http://www.vldb.org/pvldb/ vol8/p1792-Akidau.pdf

10. Flink关键特性:Stream SQL Flink key features: Stream SQL select * form product from table1 where amout > 2 union (select * from table 2) 逻辑图和物理理图⼀一致

11. Flink关键特性:扩展的类库 Flink key features: extensible libraries CloudStream Service Stack 优雅的运⾏行行时框架, Time AI⽀支持不不够。 CEP Geo Streaming dl4j Table Gelly Table SQL ML Flink Storm Better Runtime, Spatial CEP & & ML API Library SQL graph SQL weak libraries on AI Enhanced Stream SQL How to enhance AI ability DataStream API DataSet API API based on Flink? Stream Processing Batch Processing Runtime Core Distributed Streaming DataFlow Local Cluster Huawei Cloud Runtime Single JVM

12.Flink七武器器 Flink killer features from Huawei 1. StreamingML 2. StreamingDL 3. Time GeoSpatial 4. CEP SQL 5. Cost-based Optimizer 6. Real-time visualization 7. Edge Compute: Flink-Lite

13.Flink提供了了坚实的基础,实际场景更更复杂。Flink provide solid runtime, scene is more complex.

14. SELECT c, CASE WHEN SRF_UNSUP(ARRAY[c], "numTrees=15,seed=4010") 1. StreamingML OVER (ORDER BY proctime RANGE BETWEEN INTERVAL '300' SECOND PRECEDING AND CURRENT ROW) > 0.8 THEN 'anomaly' ELSE 'not anomaly' SRF: Stream Random Forest END FROM MyTable Used in IoT or vehicle: Abnormal detection SRF_UNSUP:无监督流式随机森林 SRF_SEMI_SUP:半监督流式随机森林 SRF_SUP:监督流式随机森林 https://support.huaweicloud.com/sqlreference-cs/cs_07_0028.html

15. 3.Time GeoSpatial:实时时间地理理位置分析! SQL Time Geospatial – ⾼高级操作,在窗⼝口中的GEO函数 DDL for Time Geospatial – 基本元素 1. ST_Point(latitude, longitude) 纬度和 1. AGG_DISTANCE(point) 计算窗⼝口时间内覆盖的距离 经度构成点! 2. ST_Line(array[point1...pointN]) 多 示例例: SELECT AGG_DISTANCE(ST_POINT(x,y)) OVER 点构成线! (ORDER BY proctime RANGE BETWEEN INTERVAL '10' 3. ST_POLYGON(array[point1...point1]) MINUTE PRECEDING AND CURRENT ROW) FROM input 多点构成多边形! 4. ST_CIRCLE(point, radius) 点和半径 2. AVG_SPEED 计算窗⼝口时间内的速度 构成圆! 示例例: SELECT AVG_SPEED(ST_POINT(x,y)) OVER 应⽤用场景: (PARTITION BY user ORDER BY rowtime ROWS BETWEEN 1.  偏航告警 10 PRECEDING AND CURRENT ROW) FROM input 2.  电⼦子围栏 3.  区域检测 上述函数⽀支持窗⼝口: 4.  超速检测 1. HOP/TUMBLE/OVER/SESSION windows 5.  危险驾驶⾏行行为分析 2. count/time windows 3. rowtime/proctime windows 右图,车辆提前规划好路线: 1. 车辆实时平均车速 2. 车辆一旦偏离预定路线200米, 实时告警

16. 4. CEP SQL CEP可⽤用于: 1 SELECT * FROM MyTable MATCH_RECOGNIZE 2 ( Complex Event Process SQL used for: 3 MEASURES AVG(B.id) as Bid 1.  pattern matching 模式匹配 4 ALL ROWS PER MATCH 5 PATTERN (A B C) 2.  Fraud detection 反欺诈 6 DEFINE 1.  MEASURES: 7 A AS A.name = 'a', 对配后的结果运算 8 B AS B.name = 'b', compute the matched result 9 C as C.name = 'c' 2. PATTERN: 10 ) MR 定义匹配模式 define matching pattern 4,y 4,x 4,a 1,a 2,b 3,c 3,a 3,a 4,a 9,b 7,c 3,c 0,a 3. DEFINE: 定义匹配模式所需的变量量 define variable for pattern MEASURES AVG(B.id) MEASURES AVG(B.id) 2 10 More info https://support.huaweicloud.com/sqlreference-cs/cs_07_0014.html

17. 5. Dynamic Cost-based Optimizer 动态CBO要解决的问题: Dynamic Schedule CBO Manager New DAG yarn/k8s/mesos Dynamic COB resolve problems 1.  数据倾斜引起作业崩溃 Data skew cause job shutdown 2. ⽤用于serverless的资源预估 keyBy keyBy Resource estimator for serverless 3. 作业⻓长时间运⾏行行的可靠性 Keep job long running reliably

18. 6. 实时可视化和作业即服务 Real-time visualization and job as a service Job as a Service: 1. Every Job have a unique Stream API for subscribe. 2. Source and Sink data sampling 3. Combine jobs as a “Big Screen” 4. Integrate jobs to your own system 作业即服务: 1.  每个作业都有唯⼀一的可订阅的流式API 2.  输⼊入流和输出流采样,检查数据质量量 3.  联合多个作业组成监控⼤大瓶 4.  云上作业集成到线下业务系统

19. 7.Edge Compute: Flink-Lite Why does Edge choose stream framework? Flink Job 1.  Personal privacy 个⼈人隐私数据 1 2.  Industrial Formulators ⼯工业核⼼心配⽅方机密 DIS(kafka) 3.  Data too huge数据太⼤大 2 4 4.  Low latency of ms 毫秒级低延迟 Public Cloud CloudStream 5 混合云模式 Hybrid cloud: -  公有云开发应⽤用并推送到私有云 3 3 Public cloud for develop app and deploy -  私有云接收应⽤用和执⾏行行应⽤用 hybrid cloud Private cloud receive app and apply -  私有云反馈安全脱敏敏结果数据到公有云 1 Flink Runtime Feedback to cloud if security rules allow Flink SQL 2 Private Cloud Flink Jar Factory Vehicle Smart City IoT

20. 全⽣生态连接 Open Source and Coud platform 连接: 1.  开源框架 Open Source framework 2.  存储类云服务 Storage Service 3.  AI:机器器学习/图计算/深度学习/模型推理理 AI 全连接覆盖最常⽤用场景Cover most case 计算存储分离,连接更更丰富的存储 Connect more external storage system 连接不不同的系统,会有不不同的吞吐 Different external system, different throughput Flink Connectors Bahir-Flink 如何保证source输⼊入流的可靠性? How guarantee source stream data reliability? https://support.huaweicloud.com/ecodevg-cs/cs_05_0001.html

21.隔离和安全:共享模式和独享集群 isolation & exclusive cluster 独享集群特点Characteristics of exclusive cluster : - 资源隔离 Resource isolation - 专⽤用集群,⽆无多⽤用户交叉. Exclusive clustor just for one tenant - 业务隔离 Business scene isolation 如消防IoT设备在同⼀一个集群中管理理连接、数据和计算,⽆无⼲干扰 Flink Job For example a group of IoT sensors data analyze are isolated in exclusive cluster. 沙箱问题Sand box problem Spark Job -  沙箱⽆无法解决所有安全问题,⽭矛盾。Language sandbox can’t resolve security exhaustive -  通过硬件和VM隔离。粗暴暴有效。Hardware and VMs are isolated, which solves security problems. Flink job Severless: -  弹性伸缩 Auto scaling -  按需收费,作业⽤用多少算多少. Pay-per-use billing mode. You 1 2 3 Edge job only need to pay for the resources you use.

22.Flink⾏行行业应⽤用场景: ⻋车联⽹网 Flink Industry Use Case:Intelligent Vehicle ⻋车联⽹网⾏行行业,基础设施已成熟 实时数据:基于位置、CAN数据、语 ⾳音、视频数据的实时分析 改善体验: ⼈人机交互 100 9 8 0 7 0 智能座舱 60 5 0 04 3 0 OTA在线升级 2 0 10 0 0 toD n JA M g eO p cN J aF b aA ary J uS M 新能源 v e ne rp u ul c 100 共享:⻋车、单⻋车、电动⻋车 90 80 70 60 50 … … 40 30 20 10 0 eM eO cN u A pM J F aA a J uS D u J o a e g t v n b r r n p c y l ⼤大数据AI使能

23.典型场景:驾驶⾏行行为管理理解决⽅方案 Driving bahavior anlysitic 客户价值 驾驶行为分析 不良驾驶行为分析 异常事件分析 驾驶行为评分 深入了解驾驶员的驾驶行为有助制定更为合理的交通法规并 设计更加有效地智能驾驶系统,从而达到减少交通事故、提 ü  急加、急减 ü  怠速异常检测及分 ü  车速区间统计 ü  车主驾驶行为综 高交通效率的目的。 ü  发动机转速区间统计 ü  空挡滑行 析 合分析 ü  油门开度区间统计 ü  冷启动未暖车 ü  异常油耗波动分析 ü  怠速油耗分析 ü  超速、超转 关键技术 ü  疲劳驾驶检测 OBD ü  刹车里程及次数分析 1.  实时流复杂事件处理能力:CloudStream提供CEP on SQL的能力, 提供基于规则的异常行为检测。 2.  计算查询优化:业界先进的CarbonData存储技术,结合分区表,缓 实时流分析 存加速,索引下压等技术加速查询性能,并提供基于OBS的 (CloudStream) 多元融合 疲劳驾驶检测 SparkSQL计算引擎。 T-box 基于规则实时驾 (DLS深度学习) 驶异常行为检测 3.  人脸识别能力:快速检测多达74个人脸关键点,识别效果更精 视频分析 准,在背景复杂的图像中依然拥有良好表现。并提供RESTful IoT 车辆数据 API接口及SDK,方便客户使用与集成。 Hu 实时接入 驾驶行为统计分析 车载摄像头 b 驾驶行为评分 (DIS) (DLI离线分析) (MLS机器学习) 4.  图像识别能力:有效识别多达23000个标签,识别更精准。单张 多维报表 数据挖掘 图像识别速度小于0.1秒。 5.  丰富的驾驶行为评分基础算法:基于workflow提供回归类性能深 历史数据存储(OBS) 度优化算法,随机森林林,GBDT等。 驾驶员识别 环境识别 6.  基于GPU的深度学习引擎:提供物体检测、视频分析等几十种 (人脸识 (图像识 CNN/RNN神经网络算法模型; 提供大量基于开源数据集训练好的 别) 别) 模型,方便用户加快模型训练;方便客户基于T-BOX、OBD及车 车企公有云平台 载摄像头完成深度数据挖掘。

24. 典型场景:城市智能体 Smart City 1.  自动回归学习 2.  在线机器学习算法 3.  自动选择最优算法 4.  在线训练模型 离线模型! 加载模型 TensorFlow! TensorFlow Mini-Flink AI模型 视频流 数据流 边缘计算 Flink:增量量训练 推理理 华为云 实时流计算服务!

25.Flink SQL在线体验 Online Flink SQL in practice See the StreamingML demo Demo step by step: https://github.com/huaweicloud/huaweicloud-cs-sdk/blob/master/huaweicloud-cs-examples/ StreamingML_abnormal_detection_example.md

26.