SlideShare a Scribd company logo
Resilient Predictive Data
Pipelines
Sid Anand (@r39132)
QCon London 2016
1
About Me
2
Work [ed | s] @
Maintainer on
Report to
Co-Chair for
airbnb/airflow
Motivation
Why is a Data Pipeline talk in this High
Availability Track?
3
Different Types of Data Pipelines
4
ETL
β€’ used for : loading data related
to business health into a Data
Warehouse
β€’ user-engagement stats (e.g.
social networking)
β€’ product success stats (e.g.
e-commerce)
β€’ audience : Business, BizOps
β€’ downtime? : 1-3 days
Predictive
β€’ used for :
β€’building recommendation
products (e.g. social
networking, shopping)
β€’updating fraud prevention
endpoints (e.g. security,
payments, e-commerce)
β€’ audience : Customers
β€’ downtime? : < 1 hour
VS
5
ETL
β€’ used for
Data Warehouse β€”> Reports
β€’ user-engagement stats (
social networking
β€’ product success stats (
e-commerce
β€’ audience
β€’ downtime?
Predictive
β€’ used for :
β€’building recommendation
products (e.g. social
networking, shopping)
β€’updating fraud prevention
endpoints (e.g. security,
payments, e-commerce)
β€’ audience : Customers
β€’ downtime? : < 1 hour
VS
Different Types of Data Pipelines
Why Do We Care About Resilience?
6
d4d5d6d7d8
DB
Search
Engines
Recommenders
d1 d2 d3
DB
Why Do We Care About Resilience?
7
d4
d6d7d8
Search
Engines
Recommenders
d1 d2 d3
d5
Why Do We Care About Resilience?
8
d7d8
DB
Search
Engines
Recommenders
d1 d2 d3 d4
d5
d6
Why Do We Care About Resilience?
9
d7d8
DB
Search
Engines
Recommenders
d1 d2 d3 d4
d5
d6
Any Take-aways?
10
d7d8
DB
Search
Engines
Recommenders
d1 d2 d3 d4
d5
d6
β€’ Bugs happen!
β€’ Bugs in Predictive Data Pipelines have a large blast
radius
β€’ The bugs can affect customers and a company’s
profits & reputation!
Design Goals
Desirable Qualities of a Resilient Data Pipeline
11
12
β€’ Scalable
β€’ Available
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Quickly Recoverable
Desirable Qualities of a Resilient
Data Pipeline
13
β€’ Scalable
β€’ Build your pipelines using [infinitely] scalable components
β€’ The scalability of your system is determined by its least-scalable
component
β€’ Available
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Quickly Recoverable
Desirable Qualities of a Resilient
Data Pipeline
Desirable Qualities of a Resilient
Data Pipeline
14
β€’ Scalable
β€’ Build your pipelines using [infinitely] scalable components
β€’ The scalability of your system is determined by its least-scalable
component
β€’ Available
β€’ Ditto
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Quickly Recoverable
Instrumented
15
Instrumentation must reveal SLA metrics at each stage of the pipeline!
What SLA metrics do we care about? Correctness & Timeliness
β€’ Correctness
β€’ No Data Loss
β€’ No Data Corruption
β€’ No Data Duplication
β€’ A Defined Acceptable Staleness of Intermediate Data
β€’ Timeliness
β€’ A late result == a useless result
β€’ Delayed processing of now()’s data may delay the processing of future
data
Instrumented, Monitored, & Alert-
enabled
16
β€’ Instrument
β€’ Instrument Correctness & Timeliness SLA metrics at each stage of the
pipeline
β€’ Monitor
β€’ Continuously monitor that SLA metrics fall within acceptable bounds (i.e.
pre-defined SLAs)
β€’ Alert
β€’ Alert when we miss SLAs
Desirable Qualities of a Resilient
Data Pipeline
17
β€’ Scalable
β€’ Build your pipelines using [infinitely] scalable components
β€’ The scalability of your system is determined by its least-scalable
component
β€’ Available
β€’ Ditto
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Quickly Recoverable
Quickly Recoverable
18
β€’ Bugs happen!
β€’ Bugs in Predictive Data Pipelines have a large blast radius
β€’ Optimize for MTTR
Implementation
Using AWS to meet Design Goals
19
SQS
Simple Queue Service
20
SQS - Overview
21
AWS’s low-latency, highly scalable, highly available message queue
Infinitely Scalable Queue (though not FIFO)
Low End-to-end latency (generally sub-second)
Pull-based
How it Works!
Producers publish messages, which can be batched, to an SQS queue
Consumers
consume messages, which can be batched, from the queue
commit message contents to a data store
ACK the messages as a batch
visibility
timer
SQS - Typical Operation Flow
22
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 1: A consumer reads a message from
SQS. This starts a visibility timer!
visibility
timer
SQS - Typical Operation Flow
23
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 2: Consumer persists message
contents to DB
visibility
timer
SQS - Typical Operation Flow
24
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 3: Consumer ACKs message in SQS
visibility
timer
SQS - Time Out Example
25
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 1: A consumer reads a message from
SQS
visibility
timer
SQS - Time Out Example
26
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 2: Consumer attempts persists
message contents to DB
visibility
time out
SQS - Time Out Example
27
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 3: A Visibility Timeout occurs & the
message becomes visible again.
visibility
timer
SQS - Time Out Example
28
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
m1
SQS
Step 4: Another consumer reads and
persists the same message
visibility
timer
SQS - Time Out Example
29
Producer
Producer
Producer
m1m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Step 5: Consumer ACKs message in SQS
SQS - Dead Letter Queue
30
SQS - DLQ
visibility
timer
Producer
Producer
Producer
m2m3m4m5
Consumer
Consumer
Consumer
DB
m1
SQS
Redrive
rule : 2x
m1
SNS
Simple Notification Service
31
SNS - Overview
32
Highly Scalable, Highly Available, Push-based Topic Service
Whereas SQS ensures each message is seen by at least 1 consumer
SNS ensures that each message is seen by every consumer
Reliable Multi-Push
Whereas SQS is pull-based, SNS is push-based
There is no message retention & there is a finite retry count
No Reliable Message Delivery
Can we work around this limitation?
SNS + SQS Design Pattern
33
m1m2
m1m2
m1m2
SQS Q1
SQS Q2
SNS T1
Reliable
Multi
Push
Reliable
Message
Delivery
SNS + SQS
34
Producer
Producer
Producer
m1m2
Consumer
Consumer
Consumer
DB
m1
m1m2
m1m2
SQS Q1
SQS Q2
SNS T1
Consumer
Consumer
Consumer
ES
m1
S3 + SNS + SQS Design Pattern
35
m1m2
m1m2
m1m2
SQS Q1
SQS Q2
SNS T1
Reliable
Multi
Push
Transactions
S3
d1
d2
Batch Pipeline Architecture
Putting the Pieces Together
36
Architecture
37
Architectural Elements
38
A Schema-aware Data format for all data (Avro)
The entire pipeline is built from Highly-Available/Highly-Scalable
components
S3, SNS, SQS, ASG, EMR Spark (exception DB)
The pipeline is never blocked because we use a DLQ for messages we
cannot process
We use queue-based auto-scaling to get high on-demand ingest rates
We manage everything with Airflow
Every stage in the pipeline is idempotent
Every stage in the pipeline is instrumented
ASG
Auto Scaling Group
39
ASG - Overview
40
What is it?
A means to automatically scale out/in
clusters to handle variable load/traffic
A means to keep a cluster/service always
up
Fulfills AWS’s pay-per-use promise!
When to use it?
Feed-processing, web traffic load
balancing, zone outage, etc…
ASG - Data Pipeline
41
importer
importer
importer
importer
Importer
ASG
scaleout/in
SQS
DB
ASG : CPU-based
42
Sent
CPU
ACKd/Recvd
CPU-based auto-scaling is
good at scaling in/out to
keep the average CPU
constant
ASG : CPU-based
43
Sent
CPU
Recv
Premature
Scale-in
Premature Scale-in: The CPU drops to noise-levels before all
messages are consumed. This causes scale in to occur while the
last few messages are still being committed resulting in a long time-
to-drain for the queue!
ASG - Queue-based
44
Scale-out: When Visible Messages > 0 (a.k.a. when queue depth > 0)
Scale-in: When Invisible Messages = 0 (a.k.a. when the last in-flight message is
ACK’d)
This causes the
ASG to grow
This causes the
ASG to shrink
Architecture
45
Reliable Hourly Job
Scheduling
Workflow Automation & Scheduling
46
47
Historical Context
Our first cut at the pipeline used cron to schedule hourly runs of Spark
Problem
We only knew if Spark succeeded. What if a downstream task failed?
We needed something smarter than cron that
Reliably managed a graph of tasks (DAG - Directed Acyclic Graph)
Orchestrated hourly runs of that DAG
Retried failed tasks
Tracked the performance of each run and its tasks
Reported on failure/success of runs
Our Needs
Airflow
Workflow Automation & Scheduling
48
Airflow - DAG Dashboard
49
Airflow: It’s easy to manage multiple DAGs
Airflow - Authoring DAGs
50
Airflow: Visualizing a DAG
51
Airflow: Author DAGs in Python! No need to bundle many config files!
Airflow - Authoring DAGs
Airflow - Performance Insights
52
Airflow: Gantt chart view reveals the slowest tasks for a run!
53
Airflow: …And we can easily see performance trends over time
Airflow - Performance Insights
Airflow - Alerting
54
Airflow: …And easy to integrate with Ops tools!
Airflow - Monitoring
55
56
Airflow - Join the Community
With >30 Companies, >100 Contributors , and >2500 Commits,
Airflow is growing rapidly!
We are looking for more contributors to help support the
community!
Disclaimer : I’m a maintainer on the project
Design Goal Scorecard
Are We Meeting Our Design Goals?
57
58
β€’ Scalable
β€’ Available
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Quickly Recoverable
Desirable Qualities of a Resilient
Data Pipeline
59
β€’ Scalable
β€’ Build using scalable components from AWS
β€’ SQS, SNS, S3, ASG, EMR Spark
β€’ Exception = DB (WIP)
β€’ Available
β€’ Build using available components from AWS
β€’ Airflow for reliable job scheduling
β€’ Instrumented, Monitored, & Alert-enabled
β€’ Airflow
β€’ Quickly Recoverable
β€’ Airflow, DLQs, ASGs, Spark & DB
Desirable Qualities of a Resilient
Data Pipeline
Questions? (@r39132)
60

More Related Content

PDF
Resilient Predictive Data Pipelines (GOTO Chicago 2016)
PDF
Cloud Native Data Pipelines (QCon Shanghai & Tokyo 2016)
PDF
Cloud Native Data Pipelines (GoTo Chicago 2017)
PDF
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
PDF
Airflow @ Agari
PPTX
Building a Modern Website for Scale (QCon NY 2013)
PPTX
Cloud Native Predictive Data Pipelines (micro talk)
PPTX
Software Developer and Architecture @ LinkedIn (QCon SF 2014)
Resilient Predictive Data Pipelines (GOTO Chicago 2016)
Cloud Native Data Pipelines (QCon Shanghai & Tokyo 2016)
Cloud Native Data Pipelines (GoTo Chicago 2017)
Cloud Native Data Pipelines (in Eng & Japanese) - QCon Tokyo
Airflow @ Agari
Building a Modern Website for Scale (QCon NY 2013)
Cloud Native Predictive Data Pipelines (micro talk)
Software Developer and Architecture @ LinkedIn (QCon SF 2014)

What's hot (20)

PDF
Data Processing with Apache Spark Meetup Talk
PDF
Lambda at Weather Scale by Robbie Strickland
PDF
8 Lessons Learned from Using Kafka in 1500 microservices - confluent streamin...
PPT
What Crimean War gunboats teach us about the need for schema registries
PPTX
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
PPTX
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
PPTX
Extending the Yahoo Streaming Benchmark
PDF
Spark streaming + kafka 0.10
PPTX
Being Ready for Apache Kafka - Apache: Big Data Europe 2015
PDF
Building Stream Processing Applications with Apache Kafka Using KSQL (Robin M...
PDF
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
PDF
[Spark Summit EU 2017] Apache spark streaming + kafka 0.10 an integration story
PDF
Flink at netflix paypal speaker series
PDF
Blueflood: Open Source Metrics Processing at CassandraEU 2013
PDF
Blueflood and Beyond: The Future of Metrics - Berlin Buzzwords 2014
PDF
Apache Kafka - Scalable Message-Processing and more !
PDF
Apache Storm vs. Spark Streaming – two Stream Processing Platforms compared
PDF
Large-Scale ETL Data Flows With Data Pipeline and Dataduct
PDF
Ultimate journey towards realtime data platform with 2.5M events per sec
PDF
Moon soo Lee – Data Science Lifecycle with Apache Flink and Apache Zeppelin
Data Processing with Apache Spark Meetup Talk
Lambda at Weather Scale by Robbie Strickland
8 Lessons Learned from Using Kafka in 1500 microservices - confluent streamin...
What Crimean War gunboats teach us about the need for schema registries
Extending the Yahoo Streaming Benchmark + MapR Benchmarks
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
Extending the Yahoo Streaming Benchmark
Spark streaming + kafka 0.10
Being Ready for Apache Kafka - Apache: Big Data Europe 2015
Building Stream Processing Applications with Apache Kafka Using KSQL (Robin M...
ApacheCon Berlin 2019: Kongo:Building a Scalable Streaming IoT Application us...
[Spark Summit EU 2017] Apache spark streaming + kafka 0.10 an integration story
Flink at netflix paypal speaker series
Blueflood: Open Source Metrics Processing at CassandraEU 2013
Blueflood and Beyond: The Future of Metrics - Berlin Buzzwords 2014
Apache Kafka - Scalable Message-Processing and more !
Apache Storm vs. Spark Streaming – two Stream Processing Platforms compared
Large-Scale ETL Data Flows With Data Pipeline and Dataduct
Ultimate journey towards realtime data platform with 2.5M events per sec
Moon soo Lee – Data Science Lifecycle with Apache Flink and Apache Zeppelin
Ad

Similar to Resilient Predictive Data Pipelines (QCon London 2016) (20)

PDF
Cloud Native Data Pipelines
PDF
Introduction to Apache Airflow - Data Day Seattle 2016
PDF
Cloud Native Data Pipelines (DataEngConf SF 2017)
PDF
Building highly reliable data pipeline @datadog par Quentin FranΓ§ois
PDF
Let's take the monolith to the cloud πŸš€
PDF
OSMC 2019 | Monitoring Event Pipelines: Why you need one, and why you should ...
PDF
Monoliths to the cloud!
PDF
Data pipelines from zero to solid
PPTX
Captial One: Why Stream Data as Part of Data Transformation?
PDF
Distributed Near Real-Time Processing of Sensor Network Data Flows for Smart ...
PDF
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
PPT
Resilience: the key requirement of a [big] [data] architecture - StampedeCon...
PDF
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
PDF
End-to-end pipeline agility - Berlin Buzzwords 2024
PDF
Evolution of AWS infrastructure for ML: from Zero to Hero
PDF
C19013010 the tutorial to build shared ai services session 2
PDF
Lightweight and scalable IoT Architectures with MQTT
PDF
Can I order some servers for my serverless please-London VMUG 2017
PDF
Online Meetup #3 - Solo.io, Tidepool, Weaveworks, Buoyant
PDF
Data ops in practice - Swedish style
Cloud Native Data Pipelines
Introduction to Apache Airflow - Data Day Seattle 2016
Cloud Native Data Pipelines (DataEngConf SF 2017)
Building highly reliable data pipeline @datadog par Quentin FranΓ§ois
Let's take the monolith to the cloud πŸš€
OSMC 2019 | Monitoring Event Pipelines: Why you need one, and why you should ...
Monoliths to the cloud!
Data pipelines from zero to solid
Captial One: Why Stream Data as Part of Data Transformation?
Distributed Near Real-Time Processing of Sensor Network Data Flows for Smart ...
Functioning incessantly of Data Science Platform with Kubeflow - Albert Lewan...
Resilience: the key requirement of a [big] [data] architecture - StampedeCon...
DevOps in the Amazon Cloud – Learn from the pioneersNetflix suro
End-to-end pipeline agility - Berlin Buzzwords 2024
Evolution of AWS infrastructure for ML: from Zero to Hero
C19013010 the tutorial to build shared ai services session 2
Lightweight and scalable IoT Architectures with MQTT
Can I order some servers for my serverless please-London VMUG 2017
Online Meetup #3 - Solo.io, Tidepool, Weaveworks, Buoyant
Data ops in practice - Swedish style
Ad

More from Sid Anand (17)

PDF
Building High Fidelity Data Streams (QCon London 2023)
PDF
Building & Operating High-Fidelity Data Streams - QCon Plus 2021
PDF
Low Latency Fraud Detection & Prevention
PDF
YOW! Data Keynote (2021)
PDF
Big Data, Fast Data @ PayPal (YOW 2018)
PDF
Building Better Data Pipelines using Apache Airflow
PPTX
LinkedIn's Segmentation & Targeting Platform (Hadoop Summit 2013)
PDF
Hands On with Maven
PDF
Learning git
PDF
LinkedIn Data Infrastructure Slides (Version 2)
PDF
LinkedIn Data Infrastructure (QCon London 2012)
PPTX
Linked in nosql_atnetflix_2012_v1
PDF
Keeping Movies Running Amid Thunderstorms!
PDF
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
PDF
Intuit CTOF 2011 - Netflix for Mobile in the Cloud
PPTX
Svccg nosql 2011_v4
PPTX
Netflix's Transition to High-Availability Storage (QCon SF 2010)
Building High Fidelity Data Streams (QCon London 2023)
Building & Operating High-Fidelity Data Streams - QCon Plus 2021
Low Latency Fraud Detection & Prevention
YOW! Data Keynote (2021)
Big Data, Fast Data @ PayPal (YOW 2018)
Building Better Data Pipelines using Apache Airflow
LinkedIn's Segmentation & Targeting Platform (Hadoop Summit 2013)
Hands On with Maven
Learning git
LinkedIn Data Infrastructure Slides (Version 2)
LinkedIn Data Infrastructure (QCon London 2012)
Linked in nosql_atnetflix_2012_v1
Keeping Movies Running Amid Thunderstorms!
OSCON Data 2011 -- NoSQL @ Netflix, Part 2
Intuit CTOF 2011 - Netflix for Mobile in the Cloud
Svccg nosql 2011_v4
Netflix's Transition to High-Availability Storage (QCon SF 2010)

Recently uploaded (20)

PDF
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Β 
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
The Internet -By the Numbers, Sri Lanka Edition
Β 
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PDF
SASE Traffic Flow - ZTNA Connector-1.pdf
PDF
Sims 4 Historia para lo sims 4 para jugar
PPT
tcp ip networks nd ip layering assotred slides
PDF
The New Creative Director: How AI Tools for Social Media Content Creation Are...
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
Β 
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
PPTX
Internet___Basics___Styled_ presentation
PPTX
QR Codes Qr codecodecodecodecocodedecodecode
PPTX
Digital Literacy And Online Safety on internet
PPTX
innovation process that make everything different.pptx
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
πŸ’° π”πŠπ“πˆ πŠπ„πŒπ„ππ€ππ†π€π πŠπˆππ„π‘πŸ’πƒ π‡π€π‘πˆ 𝐈𝐍𝐈 πŸπŸŽπŸπŸ“ πŸ’°
Β 
SAP Ariba Sourcing PPT for learning material
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Β 
Introuction about WHO-FIC in ICD-10.pptx
The Internet -By the Numbers, Sri Lanka Edition
Β 
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Decoding a Decade: 10 Years of Applied CTI Discipline
SASE Traffic Flow - ZTNA Connector-1.pdf
Sims 4 Historia para lo sims 4 para jugar
tcp ip networks nd ip layering assotred slides
The New Creative Director: How AI Tools for Social Media Content Creation Are...
RPKI Status Update, presented by Makito Lay at IDNOG 10
Β 
An introduction to the IFRS (ISSB) Stndards.pdf
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Internet___Basics___Styled_ presentation
QR Codes Qr codecodecodecodecocodedecodecode
Digital Literacy And Online Safety on internet
innovation process that make everything different.pptx
PptxGenJS_Demo_Chart_20250317130215833.pptx
Design_with_Watersergyerge45hrbgre4top (1).ppt

Resilient Predictive Data Pipelines (QCon London 2016)

  • 1. Resilient Predictive Data Pipelines Sid Anand (@r39132) QCon London 2016 1
  • 2. About Me 2 Work [ed | s] @ Maintainer on Report to Co-Chair for airbnb/airflow
  • 3. Motivation Why is a Data Pipeline talk in this High Availability Track? 3
  • 4. Different Types of Data Pipelines 4 ETL β€’ used for : loading data related to business health into a Data Warehouse β€’ user-engagement stats (e.g. social networking) β€’ product success stats (e.g. e-commerce) β€’ audience : Business, BizOps β€’ downtime? : 1-3 days Predictive β€’ used for : β€’building recommendation products (e.g. social networking, shopping) β€’updating fraud prevention endpoints (e.g. security, payments, e-commerce) β€’ audience : Customers β€’ downtime? : < 1 hour VS
  • 5. 5 ETL β€’ used for Data Warehouse β€”> Reports β€’ user-engagement stats ( social networking β€’ product success stats ( e-commerce β€’ audience β€’ downtime? Predictive β€’ used for : β€’building recommendation products (e.g. social networking, shopping) β€’updating fraud prevention endpoints (e.g. security, payments, e-commerce) β€’ audience : Customers β€’ downtime? : < 1 hour VS Different Types of Data Pipelines
  • 6. Why Do We Care About Resilience? 6 d4d5d6d7d8 DB Search Engines Recommenders d1 d2 d3
  • 7. DB Why Do We Care About Resilience? 7 d4 d6d7d8 Search Engines Recommenders d1 d2 d3 d5
  • 8. Why Do We Care About Resilience? 8 d7d8 DB Search Engines Recommenders d1 d2 d3 d4 d5 d6
  • 9. Why Do We Care About Resilience? 9 d7d8 DB Search Engines Recommenders d1 d2 d3 d4 d5 d6
  • 10. Any Take-aways? 10 d7d8 DB Search Engines Recommenders d1 d2 d3 d4 d5 d6 β€’ Bugs happen! β€’ Bugs in Predictive Data Pipelines have a large blast radius β€’ The bugs can affect customers and a company’s profits & reputation!
  • 11. Design Goals Desirable Qualities of a Resilient Data Pipeline 11
  • 12. 12 β€’ Scalable β€’ Available β€’ Instrumented, Monitored, & Alert-enabled β€’ Quickly Recoverable Desirable Qualities of a Resilient Data Pipeline
  • 13. 13 β€’ Scalable β€’ Build your pipelines using [infinitely] scalable components β€’ The scalability of your system is determined by its least-scalable component β€’ Available β€’ Instrumented, Monitored, & Alert-enabled β€’ Quickly Recoverable Desirable Qualities of a Resilient Data Pipeline
  • 14. Desirable Qualities of a Resilient Data Pipeline 14 β€’ Scalable β€’ Build your pipelines using [infinitely] scalable components β€’ The scalability of your system is determined by its least-scalable component β€’ Available β€’ Ditto β€’ Instrumented, Monitored, & Alert-enabled β€’ Quickly Recoverable
  • 15. Instrumented 15 Instrumentation must reveal SLA metrics at each stage of the pipeline! What SLA metrics do we care about? Correctness & Timeliness β€’ Correctness β€’ No Data Loss β€’ No Data Corruption β€’ No Data Duplication β€’ A Defined Acceptable Staleness of Intermediate Data β€’ Timeliness β€’ A late result == a useless result β€’ Delayed processing of now()’s data may delay the processing of future data
  • 16. Instrumented, Monitored, & Alert- enabled 16 β€’ Instrument β€’ Instrument Correctness & Timeliness SLA metrics at each stage of the pipeline β€’ Monitor β€’ Continuously monitor that SLA metrics fall within acceptable bounds (i.e. pre-defined SLAs) β€’ Alert β€’ Alert when we miss SLAs
  • 17. Desirable Qualities of a Resilient Data Pipeline 17 β€’ Scalable β€’ Build your pipelines using [infinitely] scalable components β€’ The scalability of your system is determined by its least-scalable component β€’ Available β€’ Ditto β€’ Instrumented, Monitored, & Alert-enabled β€’ Quickly Recoverable
  • 18. Quickly Recoverable 18 β€’ Bugs happen! β€’ Bugs in Predictive Data Pipelines have a large blast radius β€’ Optimize for MTTR
  • 19. Implementation Using AWS to meet Design Goals 19
  • 21. SQS - Overview 21 AWS’s low-latency, highly scalable, highly available message queue Infinitely Scalable Queue (though not FIFO) Low End-to-end latency (generally sub-second) Pull-based How it Works! Producers publish messages, which can be batched, to an SQS queue Consumers consume messages, which can be batched, from the queue commit message contents to a data store ACK the messages as a batch
  • 22. visibility timer SQS - Typical Operation Flow 22 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 1: A consumer reads a message from SQS. This starts a visibility timer!
  • 23. visibility timer SQS - Typical Operation Flow 23 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 2: Consumer persists message contents to DB
  • 24. visibility timer SQS - Typical Operation Flow 24 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 3: Consumer ACKs message in SQS
  • 25. visibility timer SQS - Time Out Example 25 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 1: A consumer reads a message from SQS
  • 26. visibility timer SQS - Time Out Example 26 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 2: Consumer attempts persists message contents to DB
  • 27. visibility time out SQS - Time Out Example 27 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 3: A Visibility Timeout occurs & the message becomes visible again.
  • 28. visibility timer SQS - Time Out Example 28 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 m1 SQS Step 4: Another consumer reads and persists the same message
  • 29. visibility timer SQS - Time Out Example 29 Producer Producer Producer m1m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Step 5: Consumer ACKs message in SQS
  • 30. SQS - Dead Letter Queue 30 SQS - DLQ visibility timer Producer Producer Producer m2m3m4m5 Consumer Consumer Consumer DB m1 SQS Redrive rule : 2x m1
  • 32. SNS - Overview 32 Highly Scalable, Highly Available, Push-based Topic Service Whereas SQS ensures each message is seen by at least 1 consumer SNS ensures that each message is seen by every consumer Reliable Multi-Push Whereas SQS is pull-based, SNS is push-based There is no message retention & there is a finite retry count No Reliable Message Delivery Can we work around this limitation?
  • 33. SNS + SQS Design Pattern 33 m1m2 m1m2 m1m2 SQS Q1 SQS Q2 SNS T1 Reliable Multi Push Reliable Message Delivery
  • 35. S3 + SNS + SQS Design Pattern 35 m1m2 m1m2 m1m2 SQS Q1 SQS Q2 SNS T1 Reliable Multi Push Transactions S3 d1 d2
  • 36. Batch Pipeline Architecture Putting the Pieces Together 36
  • 38. Architectural Elements 38 A Schema-aware Data format for all data (Avro) The entire pipeline is built from Highly-Available/Highly-Scalable components S3, SNS, SQS, ASG, EMR Spark (exception DB) The pipeline is never blocked because we use a DLQ for messages we cannot process We use queue-based auto-scaling to get high on-demand ingest rates We manage everything with Airflow Every stage in the pipeline is idempotent Every stage in the pipeline is instrumented
  • 40. ASG - Overview 40 What is it? A means to automatically scale out/in clusters to handle variable load/traffic A means to keep a cluster/service always up Fulfills AWS’s pay-per-use promise! When to use it? Feed-processing, web traffic load balancing, zone outage, etc…
  • 41. ASG - Data Pipeline 41 importer importer importer importer Importer ASG scaleout/in SQS DB
  • 42. ASG : CPU-based 42 Sent CPU ACKd/Recvd CPU-based auto-scaling is good at scaling in/out to keep the average CPU constant
  • 43. ASG : CPU-based 43 Sent CPU Recv Premature Scale-in Premature Scale-in: The CPU drops to noise-levels before all messages are consumed. This causes scale in to occur while the last few messages are still being committed resulting in a long time- to-drain for the queue!
  • 44. ASG - Queue-based 44 Scale-out: When Visible Messages > 0 (a.k.a. when queue depth > 0) Scale-in: When Invisible Messages = 0 (a.k.a. when the last in-flight message is ACK’d) This causes the ASG to grow This causes the ASG to shrink
  • 46. Reliable Hourly Job Scheduling Workflow Automation & Scheduling 46
  • 47. 47 Historical Context Our first cut at the pipeline used cron to schedule hourly runs of Spark Problem We only knew if Spark succeeded. What if a downstream task failed? We needed something smarter than cron that Reliably managed a graph of tasks (DAG - Directed Acyclic Graph) Orchestrated hourly runs of that DAG Retried failed tasks Tracked the performance of each run and its tasks Reported on failure/success of runs Our Needs
  • 49. Airflow - DAG Dashboard 49 Airflow: It’s easy to manage multiple DAGs
  • 50. Airflow - Authoring DAGs 50 Airflow: Visualizing a DAG
  • 51. 51 Airflow: Author DAGs in Python! No need to bundle many config files! Airflow - Authoring DAGs
  • 52. Airflow - Performance Insights 52 Airflow: Gantt chart view reveals the slowest tasks for a run!
  • 53. 53 Airflow: …And we can easily see performance trends over time Airflow - Performance Insights
  • 54. Airflow - Alerting 54 Airflow: …And easy to integrate with Ops tools!
  • 56. 56 Airflow - Join the Community With >30 Companies, >100 Contributors , and >2500 Commits, Airflow is growing rapidly! We are looking for more contributors to help support the community! Disclaimer : I’m a maintainer on the project
  • 57. Design Goal Scorecard Are We Meeting Our Design Goals? 57
  • 58. 58 β€’ Scalable β€’ Available β€’ Instrumented, Monitored, & Alert-enabled β€’ Quickly Recoverable Desirable Qualities of a Resilient Data Pipeline
  • 59. 59 β€’ Scalable β€’ Build using scalable components from AWS β€’ SQS, SNS, S3, ASG, EMR Spark β€’ Exception = DB (WIP) β€’ Available β€’ Build using available components from AWS β€’ Airflow for reliable job scheduling β€’ Instrumented, Monitored, & Alert-enabled β€’ Airflow β€’ Quickly Recoverable β€’ Airflow, DLQs, ASGs, Spark & DB Desirable Qualities of a Resilient Data Pipeline