SlideShare uma empresa Scribd logo
1 de 34
Flink SQL & Table API in Large Scale
Production at Alibaba
Xiaowei Jiang
Shaoxuan Wang
June, 2017
About Us
Xiaowei Jiang
• 2014-now Alibaba
• 2010-2014 Facebook
• 2002-2010 Microsoft
• 2000-2002 Stratify
Shaoxuan Wang
• 2015-now Alibaba
• 2014-2015 Facebook
• 2010-2014 Broadcom
Outline
1 Background
2 Why SQL & Table API
3 Blink SQL & Table API
4 Blink SQL & Table API in Large Scale Production
Background
Section 1
About Alibaba
Alibaba Group
• Operates the world’s largest e-commerce platform
• Recorded GMV of $485 Billion in year 2016, $17.8 billion worth of GMV in a single day on Nov 11, 2016
Realtime Data Infrastructure
• Supports internal products such as search, recommendation, BI
• Also supports external customers through its cloud service
Blink – Alibaba’s version of Flink
Looked into Flink two years ago
• best choice of unified computing engine
• a few issues in Flink that can be problems for large scale applications
Started “Blink” project
• aimed to make Flink work reliably and efficiently at the very large scale at Alibaba
Made various improvements in Flink runtime
Enhanced Flink SQL & Table API to production ready
Working with Flink community to contribute back since last August
• several key improvements
• hundreds of patches
Blink Ecosystem in Alibaba
Cluster Resource Management (Yarn/Fuxi)
Search
Storage (HDFS/Pangu)
SQL & Table API
Blink
Products Recommendation BI Security
DataStream API
Runtime Engine
Ads
DataSet API
Machine Learning Platform StreamCompute PlatformPlatform
Why SQL & Table API
Section 2
Why SQL & Table API
Unified batch and streaming
• Flink currently offers DataSet API for batch and DataStream API for streaming
• We want a single API that can run in both batch and streaming mode
Improved development efficiency
• Users only describe the semantics of data processing
• Leave hard optimization problems to the system
• SQL is proven to be good at describing data processing
• Table API offers seamless integration with Scala and Java
• Table API makes it easy to extend standard SQL when necessary
Stream-Table Duality
word count
Hello 3
World 1
Bark 1
word count
Hello 1
World 1
Hello 2
Bark 1
Hello 3
Stream
Dynamic Table
Apply
Changelog
Dynamic Tables
Apply Changelog Stream to Dynamic Table
• Append Mode: each stream record is an insert to the dynamic table. Hence, all records of a stream are
appended to the dynamic table
• Update Mode: a stream record can represent an insert, update, or delete modification on the dynamic
table (append mode is in fact a special case of update mode)
Derive Changelog Stream from Dynamic Table
• REDO Mode: where the stream records the new value of a modified element to redo lost changes of
completed transactions
• REDO+UNDO Mode: where the stream records the old and the new value of a changed element to undo
incomplete transactions and redo lost changes of completed transactions
Dynamic Tables
There is no such thing as Stream SQL
Stream SQL?
Dynamic Tables generalize the concept of Static Tables
SQL serves as the unified way to describe data processing in both batch and streaming
Blink SQL & Table API
Section 3
Blink SQL & Table API Overview
Simple Query: Select and Where
Stream-Stream Inner Join
User Defined Function (UDF)
User Defined Table Function (UDTF)
User Defined Aggregate Function (UDAGG)
Retraction (stream only)
Aggregate
A Simple Query: Select and Where
id name price sales stock
1 Latte 6 1 1000
8 Mocha 8 1 800
4 Breve 5 1 200
7 Tea 4 1 2000
1 Latte 6 2 998
id name price sales stock
1 Latte 6 1 1000
1 Latte 6 2 998
Stream-Stream Inner Join
id1 name stock
1 Latte 1000
8 Mocha 800
4 Breve 200
3 Water 5000
7 Tea 2000
id2 price sales
1 6 1
8 8 1
9 3 1
4 5 1
7 4 1
id name price sales stock
1 Latte 6 1 1000
8 Mocha 8 1 800
4 Breve 5 1 200
7 Tea 4 1 2000
This is proposed and
discussed in FLINK-5878
User Defined Function (UDF)
UDF converts a scalar input to a scalar output. Create and use a UDF is very
simple and easy:
We have enhanced UDF/UDTF to support
variable types and variable arguments
lSum iSum
35L 1106
Scalar  Scalar
long1 long2 int1 int2 int3
10L 25L 6 100 1000
User Defined Table Function (UDTF)
name age
Tom 23
Jack 17
David 50
line
Tom#23 Jark#17 David#50
Scalar  Table (multi rows and columns)
UDTF converts a scalar input to a table output:
We have shipped UDTF in Flink release 1.2 (FLINK-4469).
“SELECT SUM(stock) as total”
Table  Scalar
User Defined Aggregate Function (UDAGG) - Motivation
total
2000
UDAGG converts a table input to a scalar output:
Flink has built-in aggregates (count, sum, avg, min, max) for SQL and table API:
What if user wants an aggregate that is not covered by built-in aggregates, say a
weighted average aggregate? We need an aggregate interface to support user
defined aggregate function.
id name price sales stock
1 Latte 6 1 1000
8 Mocha 8 1 800
4 Breve 5 1 200
UDAGG – Accumulator (ACC)
id name price sales stock
1 Latte 6 1 1000
8 Mocha 8 1 800
4 Breve 5 1 200
7 Tea 4 1 2000
1 Latte 6 2 998
UDAGG represents its
state using accumulator
UDAGG – Interface
UDAGG example: a weighted average
SQL Query
UDAGG Interface
UDAGG – Merge
Motivated by local & global aggregate (and session window merge etc.), we need a merge
method which can merge the partial aggregated accumulator into one single accumulator
How to count the total visits on TaoBao web pages in real time?
UDAGG – Retraction – Motivations
Incorrect! The freq of
cnt=1 should be 2
UDAGG – Retraction – Motivations
We need a retract method in UDAGG, which can retract the UNDO messages from the
accumulator
Retraction – Solution
The design doc and the progress of
retraction implementation are
tracked in FLINK-6047. We have
delivered this in Flink release 1.3
Retraction is introduced to handle
updates
We use query optimizer to decide
where the retraction is needed.
DataStreamAgg
(Redo+Undo)
Update Table
(consume Undo log)
DataStreamAgg
(Redo)
Update Table
Append Table
TableScan without PK
(Redo)
NeedRetraction
NeedRetraction
Sink Table
(Does not needRetraction)
UpsertSink
UDAGG – Summary
Master JIRA for UDAGG is FLINK-5564. We have shipped this in Flink release 1.3.
Aggregate – Over Aggregate
time itemID avgPrice
1000 101 1
3000 201 1.5
4000 301 2
5000 101 2.2
5000 401 2.2
7000 301 2.6
8000 401 3
10000 101 2.8
time itemID price
1000 101 1
3000 201 2
4000 301 3
5000 101 1
5000 401 4
7000 301 3
8000 501 5
10000 101 1
Time based Group Aggregate is
not able to differentiate two
records with the same row time,
but Over Aggregate can.
Calculate moving average (in the past 5 seconds), and emit the result for each record
Aggregate – Summary
The design of aggregate is mainly tracked in FLIP11 (FLINK-4557). We have
delivered the above aggregates in Flink release 1.3
Grouping methods: Groupby / Over
Time types: Event time; Process time (only for stream)
Unbounded Aggregate: early-firing under a certain emit configuration (by
default it emits the result on every input record)
Windows:
• Time/Count + TUMBLE/SESSION/SLIDE window
• OVER Rows/Time Range window
Contributions to Flink SQL & Table API
Flink blog: “Continuous Queries on Dynamic Tables” (posted at
https://flink.apache.org/news/2017/04/04/dynamic-tables.html)
UDF (several improvements are released in 1.3)
UDTF (FLINK-4469, released in 1.2)
UDAGG (FLINK-5564, released in 1.3)
Retraction (FLINK-6047, released in 1.3)
Group/Over Window Aggregate (FLINK-4557, released in 1.3)
Unbounded Stream Group Aggregate (FLINK-6216, released in 1.3)
Stream-Stream Inner Join (FLINK-5878, targeted for release 1.4)
More coming…..
SQL & Table API in Large Scale Production
Section 4
SQL & Table API in Alibaba Production - example
SQL & Table API is proven to be a successful and sufficient declarative language for data processing.
Significantly reduce the development efforts to rewrite existing jobs or implement new jobs
SQL & Table API in Alibaba Production - Summary
Blink@Alibaba
In production at Alibaba for more than a year
• Hundreds of jobs
• The biggest cluster is more than 1500 nodes
• The biggest job has thousands of tasks and states over tens of TB
Blink SQL@Alibaba
In production before 2016 China Singles’ Day (biggest shopping festival, similar as black Friday in US)
• Blink jobs written by SQL & Table API are used to do real time analysis for recommendataion system, which
helps improve the targetting efficiency thereby increasing the traffic-to-sales conversion.
• The biggest SQL job has thousands of tasks and states over TB
The latest release of Blink SQL will be used to support entire Alibaba internal business and server
external customers via Alibaba Cloud streamCompute Service
Thanks
xiaowei.jxw@alibaba-inc.com
shaoxuan.wsx@alibaba-inc.com

Mais conteúdo relacionado

Mais procurados

Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
Jun Rao
 

Mais procurados (20)

Apache Kafka at LinkedIn
Apache Kafka at LinkedInApache Kafka at LinkedIn
Apache Kafka at LinkedIn
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain
 
Stream processing using Kafka
Stream processing using KafkaStream processing using Kafka
Stream processing using Kafka
 
Autoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive ModeAutoscaling Flink with Reactive Mode
Autoscaling Flink with Reactive Mode
 
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
Performance Tuning RocksDB for Kafka Streams' State Stores (Dhruba Borthakur,...
 
The top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scaleThe top 3 challenges running multi-tenant Flink at scale
The top 3 challenges running multi-tenant Flink at scale
 
Presto overview
Presto overviewPresto overview
Presto overview
 
kafka
kafkakafka
kafka
 
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
Confluent Workshop Series: ksqlDB로 스트리밍 앱 빌드
 
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 20190-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
0-60: Tesla's Streaming Data Platform ( Jesse Yates, Tesla) Kafka Summit SF 2019
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistent
 
Streaming Data Lakes using Kafka Connect + Apache Hudi | Vinoth Chandar, Apac...
Streaming Data Lakes using Kafka Connect + Apache Hudi | Vinoth Chandar, Apac...Streaming Data Lakes using Kafka Connect + Apache Hudi | Vinoth Chandar, Apac...
Streaming Data Lakes using Kafka Connect + Apache Hudi | Vinoth Chandar, Apac...
 
Introduction to Apache Flink
Introduction to Apache FlinkIntroduction to Apache Flink
Introduction to Apache Flink
 
Kafka 101
Kafka 101Kafka 101
Kafka 101
 
Understanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIsUnderstanding Query Plans and Spark UIs
Understanding Query Plans and Spark UIs
 
Unified Stream and Batch Processing with Apache Flink
Unified Stream and Batch Processing with Apache FlinkUnified Stream and Batch Processing with Apache Flink
Unified Stream and Batch Processing with Apache Flink
 
Introduction to Amazon Redshift
Introduction to Amazon RedshiftIntroduction to Amazon Redshift
Introduction to Amazon Redshift
 
Apache Hudi: The Path Forward
Apache Hudi: The Path ForwardApache Hudi: The Path Forward
Apache Hudi: The Path Forward
 

Semelhante a Flink SQL & TableAPI in Large Scale Production at Alibaba

1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part i
sqlserver.co.il
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
sam2sung2
 
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
Flink 2.0: Navigating the Future of Unified Stream and Batch ProcessingFlink 2.0: Navigating the Future of Unified Stream and Batch Processing
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
HostedbyConfluent
 
Oracle Apex Technical Introduction
Oracle Apex   Technical IntroductionOracle Apex   Technical Introduction
Oracle Apex Technical Introduction
crokitta
 
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
Zalando Technology
 

Semelhante a Flink SQL & TableAPI in Large Scale Production at Alibaba (20)

Flink Forward SF 2017: Shaoxuan Wang_Xiaowei Jiang - Blinks Improvements to F...
Flink Forward SF 2017: Shaoxuan Wang_Xiaowei Jiang - Blinks Improvements to F...Flink Forward SF 2017: Shaoxuan Wang_Xiaowei Jiang - Blinks Improvements to F...
Flink Forward SF 2017: Shaoxuan Wang_Xiaowei Jiang - Blinks Improvements to F...
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache Calcite
 
Make streaming processing towards ANSI SQL
Make streaming processing towards ANSI SQLMake streaming processing towards ANSI SQL
Make streaming processing towards ANSI SQL
 
Fabian Hueske - Taking a look under the hood of Apache Flink’s relational APIs
Fabian Hueske - Taking a look under the hood of Apache Flink’s relational APIsFabian Hueske - Taking a look under the hood of Apache Flink’s relational APIs
Fabian Hueske - Taking a look under the hood of Apache Flink’s relational APIs
 
Taking a look under the hood of Apache Flink's relational APIs.
Taking a look under the hood of Apache Flink's relational APIs.Taking a look under the hood of Apache Flink's relational APIs.
Taking a look under the hood of Apache Flink's relational APIs.
 
Flink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systemsFlink and Hive integration - unifying enterprise data processing systems
Flink and Hive integration - unifying enterprise data processing systems
 
Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...Unify Enterprise Data Processing System Platform Level Integration of Flink a...
Unify Enterprise Data Processing System Platform Level Integration of Flink a...
 
1 extreme performance - part i
1   extreme performance - part i1   extreme performance - part i
1 extreme performance - part i
 
Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...
 
Oracle applications r12.2, ebr, online patching means lot of work for devel...
Oracle applications r12.2, ebr, online patching   means lot of work for devel...Oracle applications r12.2, ebr, online patching   means lot of work for devel...
Oracle applications r12.2, ebr, online patching means lot of work for devel...
 
Virtual Flink Forward 2020: A deep dive into Flink SQL - Jark Wu
Virtual Flink Forward 2020: A deep dive into Flink SQL - Jark WuVirtual Flink Forward 2020: A deep dive into Flink SQL - Jark Wu
Virtual Flink Forward 2020: A deep dive into Flink SQL - Jark Wu
 
Db2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfallsDb2 migration -_tips,_tricks,_and_pitfalls
Db2 migration -_tips,_tricks,_and_pitfalls
 
Flink at netflix paypal speaker series
Flink at netflix   paypal speaker seriesFlink at netflix   paypal speaker series
Flink at netflix paypal speaker series
 
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
Flink 2.0: Navigating the Future of Unified Stream and Batch ProcessingFlink 2.0: Navigating the Future of Unified Stream and Batch Processing
Flink 2.0: Navigating the Future of Unified Stream and Batch Processing
 
Oracle Apex Technical Introduction
Oracle Apex   Technical IntroductionOracle Apex   Technical Introduction
Oracle Apex Technical Introduction
 
Flink Forward Berlin 2017: Fabian Hueske - Using Stream and Batch Processing ...
Flink Forward Berlin 2017: Fabian Hueske - Using Stream and Batch Processing ...Flink Forward Berlin 2017: Fabian Hueske - Using Stream and Batch Processing ...
Flink Forward Berlin 2017: Fabian Hueske - Using Stream and Batch Processing ...
 
2015 owb2 odi converter - white paper_owb_to_odi_migration_service_d&t
2015 owb2 odi converter - white paper_owb_to_odi_migration_service_d&t2015 owb2 odi converter - white paper_owb_to_odi_migration_service_d&t
2015 owb2 odi converter - white paper_owb_to_odi_migration_service_d&t
 
Extreme replication at IOUG Collaborate 15
Extreme replication at IOUG Collaborate 15Extreme replication at IOUG Collaborate 15
Extreme replication at IOUG Collaborate 15
 
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
Stream Processing using Apache Flink in Zalando's World of Microservices - Re...
 
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
Deep Dive into Spark SQL with Advanced Performance Tuning with Xiao Li & Wenc...
 

Mais de DataWorks Summit

HBase Global Indexing to support large-scale data ingestion at Uber
HBase Global Indexing to support large-scale data ingestion at UberHBase Global Indexing to support large-scale data ingestion at Uber
HBase Global Indexing to support large-scale data ingestion at Uber
DataWorks Summit
 
Security Framework for Multitenant Architecture
Security Framework for Multitenant ArchitectureSecurity Framework for Multitenant Architecture
Security Framework for Multitenant Architecture
DataWorks Summit
 
Computer Vision: Coming to a Store Near You
Computer Vision: Coming to a Store Near YouComputer Vision: Coming to a Store Near You
Computer Vision: Coming to a Store Near You
DataWorks Summit
 

Mais de DataWorks Summit (20)

Data Science Crash Course
Data Science Crash CourseData Science Crash Course
Data Science Crash Course
 
Floating on a RAFT: HBase Durability with Apache Ratis
Floating on a RAFT: HBase Durability with Apache RatisFloating on a RAFT: HBase Durability with Apache Ratis
Floating on a RAFT: HBase Durability with Apache Ratis
 
Tracking Crime as It Occurs with Apache Phoenix, Apache HBase and Apache NiFi
Tracking Crime as It Occurs with Apache Phoenix, Apache HBase and Apache NiFiTracking Crime as It Occurs with Apache Phoenix, Apache HBase and Apache NiFi
Tracking Crime as It Occurs with Apache Phoenix, Apache HBase and Apache NiFi
 
HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...
 
Optimizing Geospatial Operations with Server-side Programming in HBase and Ac...
Optimizing Geospatial Operations with Server-side Programming in HBase and Ac...Optimizing Geospatial Operations with Server-side Programming in HBase and Ac...
Optimizing Geospatial Operations with Server-side Programming in HBase and Ac...
 
Managing the Dewey Decimal System
Managing the Dewey Decimal SystemManaging the Dewey Decimal System
Managing the Dewey Decimal System
 
Practical NoSQL: Accumulo's dirlist Example
Practical NoSQL: Accumulo's dirlist ExamplePractical NoSQL: Accumulo's dirlist Example
Practical NoSQL: Accumulo's dirlist Example
 
HBase Global Indexing to support large-scale data ingestion at Uber
HBase Global Indexing to support large-scale data ingestion at UberHBase Global Indexing to support large-scale data ingestion at Uber
HBase Global Indexing to support large-scale data ingestion at Uber
 
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and PhoenixScaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
 
Building the High Speed Cybersecurity Data Pipeline Using Apache NiFi
Building the High Speed Cybersecurity Data Pipeline Using Apache NiFiBuilding the High Speed Cybersecurity Data Pipeline Using Apache NiFi
Building the High Speed Cybersecurity Data Pipeline Using Apache NiFi
 
Supporting Apache HBase : Troubleshooting and Supportability Improvements
Supporting Apache HBase : Troubleshooting and Supportability ImprovementsSupporting Apache HBase : Troubleshooting and Supportability Improvements
Supporting Apache HBase : Troubleshooting and Supportability Improvements
 
Security Framework for Multitenant Architecture
Security Framework for Multitenant ArchitectureSecurity Framework for Multitenant Architecture
Security Framework for Multitenant Architecture
 
Presto: Optimizing Performance of SQL-on-Anything Engine
Presto: Optimizing Performance of SQL-on-Anything EnginePresto: Optimizing Performance of SQL-on-Anything Engine
Presto: Optimizing Performance of SQL-on-Anything Engine
 
Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...
Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...
Introducing MlFlow: An Open Source Platform for the Machine Learning Lifecycl...
 
Extending Twitter's Data Platform to Google Cloud
Extending Twitter's Data Platform to Google CloudExtending Twitter's Data Platform to Google Cloud
Extending Twitter's Data Platform to Google Cloud
 
Event-Driven Messaging and Actions using Apache Flink and Apache NiFi
Event-Driven Messaging and Actions using Apache Flink and Apache NiFiEvent-Driven Messaging and Actions using Apache Flink and Apache NiFi
Event-Driven Messaging and Actions using Apache Flink and Apache NiFi
 
Securing Data in Hybrid on-premise and Cloud Environments using Apache Ranger
Securing Data in Hybrid on-premise and Cloud Environments using Apache RangerSecuring Data in Hybrid on-premise and Cloud Environments using Apache Ranger
Securing Data in Hybrid on-premise and Cloud Environments using Apache Ranger
 
Big Data Meets NVM: Accelerating Big Data Processing with Non-Volatile Memory...
Big Data Meets NVM: Accelerating Big Data Processing with Non-Volatile Memory...Big Data Meets NVM: Accelerating Big Data Processing with Non-Volatile Memory...
Big Data Meets NVM: Accelerating Big Data Processing with Non-Volatile Memory...
 
Computer Vision: Coming to a Store Near You
Computer Vision: Coming to a Store Near YouComputer Vision: Coming to a Store Near You
Computer Vision: Coming to a Store Near You
 
Big Data Genomics: Clustering Billions of DNA Sequences with Apache Spark
Big Data Genomics: Clustering Billions of DNA Sequences with Apache SparkBig Data Genomics: Clustering Billions of DNA Sequences with Apache Spark
Big Data Genomics: Clustering Billions of DNA Sequences with Apache Spark
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Flink SQL & TableAPI in Large Scale Production at Alibaba

  • 1. Flink SQL & Table API in Large Scale Production at Alibaba Xiaowei Jiang Shaoxuan Wang June, 2017
  • 2. About Us Xiaowei Jiang • 2014-now Alibaba • 2010-2014 Facebook • 2002-2010 Microsoft • 2000-2002 Stratify Shaoxuan Wang • 2015-now Alibaba • 2014-2015 Facebook • 2010-2014 Broadcom
  • 3. Outline 1 Background 2 Why SQL & Table API 3 Blink SQL & Table API 4 Blink SQL & Table API in Large Scale Production
  • 5. About Alibaba Alibaba Group • Operates the world’s largest e-commerce platform • Recorded GMV of $485 Billion in year 2016, $17.8 billion worth of GMV in a single day on Nov 11, 2016 Realtime Data Infrastructure • Supports internal products such as search, recommendation, BI • Also supports external customers through its cloud service
  • 6. Blink – Alibaba’s version of Flink Looked into Flink two years ago • best choice of unified computing engine • a few issues in Flink that can be problems for large scale applications Started “Blink” project • aimed to make Flink work reliably and efficiently at the very large scale at Alibaba Made various improvements in Flink runtime Enhanced Flink SQL & Table API to production ready Working with Flink community to contribute back since last August • several key improvements • hundreds of patches
  • 7. Blink Ecosystem in Alibaba Cluster Resource Management (Yarn/Fuxi) Search Storage (HDFS/Pangu) SQL & Table API Blink Products Recommendation BI Security DataStream API Runtime Engine Ads DataSet API Machine Learning Platform StreamCompute PlatformPlatform
  • 8. Why SQL & Table API Section 2
  • 9. Why SQL & Table API Unified batch and streaming • Flink currently offers DataSet API for batch and DataStream API for streaming • We want a single API that can run in both batch and streaming mode Improved development efficiency • Users only describe the semantics of data processing • Leave hard optimization problems to the system • SQL is proven to be good at describing data processing • Table API offers seamless integration with Scala and Java • Table API makes it easy to extend standard SQL when necessary
  • 10. Stream-Table Duality word count Hello 3 World 1 Bark 1 word count Hello 1 World 1 Hello 2 Bark 1 Hello 3 Stream Dynamic Table Apply Changelog
  • 11. Dynamic Tables Apply Changelog Stream to Dynamic Table • Append Mode: each stream record is an insert to the dynamic table. Hence, all records of a stream are appended to the dynamic table • Update Mode: a stream record can represent an insert, update, or delete modification on the dynamic table (append mode is in fact a special case of update mode)
  • 12. Derive Changelog Stream from Dynamic Table • REDO Mode: where the stream records the new value of a modified element to redo lost changes of completed transactions • REDO+UNDO Mode: where the stream records the old and the new value of a changed element to undo incomplete transactions and redo lost changes of completed transactions Dynamic Tables
  • 13. There is no such thing as Stream SQL Stream SQL? Dynamic Tables generalize the concept of Static Tables SQL serves as the unified way to describe data processing in both batch and streaming
  • 14. Blink SQL & Table API Section 3
  • 15. Blink SQL & Table API Overview Simple Query: Select and Where Stream-Stream Inner Join User Defined Function (UDF) User Defined Table Function (UDTF) User Defined Aggregate Function (UDAGG) Retraction (stream only) Aggregate
  • 16. A Simple Query: Select and Where id name price sales stock 1 Latte 6 1 1000 8 Mocha 8 1 800 4 Breve 5 1 200 7 Tea 4 1 2000 1 Latte 6 2 998 id name price sales stock 1 Latte 6 1 1000 1 Latte 6 2 998
  • 17. Stream-Stream Inner Join id1 name stock 1 Latte 1000 8 Mocha 800 4 Breve 200 3 Water 5000 7 Tea 2000 id2 price sales 1 6 1 8 8 1 9 3 1 4 5 1 7 4 1 id name price sales stock 1 Latte 6 1 1000 8 Mocha 8 1 800 4 Breve 5 1 200 7 Tea 4 1 2000 This is proposed and discussed in FLINK-5878
  • 18. User Defined Function (UDF) UDF converts a scalar input to a scalar output. Create and use a UDF is very simple and easy: We have enhanced UDF/UDTF to support variable types and variable arguments lSum iSum 35L 1106 Scalar  Scalar long1 long2 int1 int2 int3 10L 25L 6 100 1000
  • 19. User Defined Table Function (UDTF) name age Tom 23 Jack 17 David 50 line Tom#23 Jark#17 David#50 Scalar  Table (multi rows and columns) UDTF converts a scalar input to a table output: We have shipped UDTF in Flink release 1.2 (FLINK-4469).
  • 20. “SELECT SUM(stock) as total” Table  Scalar User Defined Aggregate Function (UDAGG) - Motivation total 2000 UDAGG converts a table input to a scalar output: Flink has built-in aggregates (count, sum, avg, min, max) for SQL and table API: What if user wants an aggregate that is not covered by built-in aggregates, say a weighted average aggregate? We need an aggregate interface to support user defined aggregate function. id name price sales stock 1 Latte 6 1 1000 8 Mocha 8 1 800 4 Breve 5 1 200
  • 21. UDAGG – Accumulator (ACC) id name price sales stock 1 Latte 6 1 1000 8 Mocha 8 1 800 4 Breve 5 1 200 7 Tea 4 1 2000 1 Latte 6 2 998 UDAGG represents its state using accumulator
  • 22. UDAGG – Interface UDAGG example: a weighted average SQL Query UDAGG Interface
  • 23. UDAGG – Merge Motivated by local & global aggregate (and session window merge etc.), we need a merge method which can merge the partial aggregated accumulator into one single accumulator How to count the total visits on TaoBao web pages in real time?
  • 24. UDAGG – Retraction – Motivations Incorrect! The freq of cnt=1 should be 2
  • 25. UDAGG – Retraction – Motivations We need a retract method in UDAGG, which can retract the UNDO messages from the accumulator
  • 26. Retraction – Solution The design doc and the progress of retraction implementation are tracked in FLINK-6047. We have delivered this in Flink release 1.3 Retraction is introduced to handle updates We use query optimizer to decide where the retraction is needed. DataStreamAgg (Redo+Undo) Update Table (consume Undo log) DataStreamAgg (Redo) Update Table Append Table TableScan without PK (Redo) NeedRetraction NeedRetraction Sink Table (Does not needRetraction) UpsertSink
  • 27. UDAGG – Summary Master JIRA for UDAGG is FLINK-5564. We have shipped this in Flink release 1.3.
  • 28. Aggregate – Over Aggregate time itemID avgPrice 1000 101 1 3000 201 1.5 4000 301 2 5000 101 2.2 5000 401 2.2 7000 301 2.6 8000 401 3 10000 101 2.8 time itemID price 1000 101 1 3000 201 2 4000 301 3 5000 101 1 5000 401 4 7000 301 3 8000 501 5 10000 101 1 Time based Group Aggregate is not able to differentiate two records with the same row time, but Over Aggregate can. Calculate moving average (in the past 5 seconds), and emit the result for each record
  • 29. Aggregate – Summary The design of aggregate is mainly tracked in FLIP11 (FLINK-4557). We have delivered the above aggregates in Flink release 1.3 Grouping methods: Groupby / Over Time types: Event time; Process time (only for stream) Unbounded Aggregate: early-firing under a certain emit configuration (by default it emits the result on every input record) Windows: • Time/Count + TUMBLE/SESSION/SLIDE window • OVER Rows/Time Range window
  • 30. Contributions to Flink SQL & Table API Flink blog: “Continuous Queries on Dynamic Tables” (posted at https://flink.apache.org/news/2017/04/04/dynamic-tables.html) UDF (several improvements are released in 1.3) UDTF (FLINK-4469, released in 1.2) UDAGG (FLINK-5564, released in 1.3) Retraction (FLINK-6047, released in 1.3) Group/Over Window Aggregate (FLINK-4557, released in 1.3) Unbounded Stream Group Aggregate (FLINK-6216, released in 1.3) Stream-Stream Inner Join (FLINK-5878, targeted for release 1.4) More coming…..
  • 31. SQL & Table API in Large Scale Production Section 4
  • 32. SQL & Table API in Alibaba Production - example SQL & Table API is proven to be a successful and sufficient declarative language for data processing. Significantly reduce the development efforts to rewrite existing jobs or implement new jobs
  • 33. SQL & Table API in Alibaba Production - Summary Blink@Alibaba In production at Alibaba for more than a year • Hundreds of jobs • The biggest cluster is more than 1500 nodes • The biggest job has thousands of tasks and states over tens of TB Blink SQL@Alibaba In production before 2016 China Singles’ Day (biggest shopping festival, similar as black Friday in US) • Blink jobs written by SQL & Table API are used to do real time analysis for recommendataion system, which helps improve the targetting efficiency thereby increasing the traffic-to-sales conversion. • The biggest SQL job has thousands of tasks and states over TB The latest release of Blink SQL will be used to support entire Alibaba internal business and server external customers via Alibaba Cloud streamCompute Service