SlideShare a Scribd company logo
1 of 51
Download to read offline
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Building Massively Parallel Event-
Driven Architectures
Amit Kulkarni
Principal Product Manager
AWS Serverless
S R V 3 7 3 - R
Mick Thompson
Data Engineer
Mapbox
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
Modern Serverless Applications
Event Delivery Concepts
Event Generation, Routing, and Processing
Real World High Scale Serverless Application
Wrap
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
THE SERVERLESS OPERATIONAL MODEL
No provisioning,
no management
Pay for value
Automatic
scaling
Highly available
and secure
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
processes 4,000 requests
per second
ingests, analyzes and
stores 17+ petabytes of
data per season
processes half a trillion
validations of stock
trades daily
executes 16 million
requests a month
processes tens of
billions of data
points monthly
SERVERLESS AT SCALE IS THE NEW NORM
API traffic to register and license
more than 47 million driver
records in Great Britain.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
High scale and resiliency at very low cost
Financial Engines AWS Lambda to power the core of its
computational “engines” which automate portfolio management
combined with access to human advisors.
Benefits of AWS Serverless
• Handles 200–300 million server requests per
month at rates of up to 60,000 per minute
• Reduced infrastructure costs by more than 90
percent
• Zero server downtime
Using AWS Lambda will
enable us to scale to serve
millions more who need
financial help.
Paul Gibson
Principal System Architect
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
SERVICES (ANYTHING)
Changes in
data state
Requests to
endpoints
Changes in
resource state
EVENT SOURCE FUNCTION
Node.js
Python
Java
C#
Go
PowerShell
Event-Driven Architecture
To grow really big in the future, you
need to think big now!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Core Concepts
Event
Generation
Event
Routing
Event
Processing
Output
Getting the event
details to processor
Emitting information
about the event
Take action on the
event
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Event Delivery – AWS Services
Event
Generation
Event
Routing
Event
Processing
Output
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Key Considerations
Event
Generation
Event
Routing
Event
Processing
Output
Payload
Persistence
Duplicates
Ordering
Retry semantics
Batching
Throughput
Concurrency
Velocity
Duration
On success / failure
Transport vs. Transform
Cost $$$
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
How do I choose?
If you know your enemies and know yourself, you will not be
imperiled in a hundred battles. - Sun Tzu, The Art of War
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Event Payload
potential_customer = {
"name":"John",
"age":30,
"cars": {
"car1":"Ford",
"car2":"BMW",
"car3":"Fiat"
}
}
Payload
Persistence
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Event Persistence
Availability
Events accessible even if source is down
Retention
Events accessible till processed
Cost
Storage, data transfer, and access
Complexity
Dependency, operational, scale
Payload
Persistence
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
No routing / default routing
Lambda
Function
Synchronous
Request-Response
Immediate access to results
You manage:
- Retries
- Ordering
- Error Handling
- Blocking and Threads
- Timeouts
Asynchronous
Fire (and forget)
Default behavior
- Retries
- Ordering
- DLQ errors
- Throughput
You manage:
- Error Response
- Duplicates Lambda
Function
S3 bucket
Duplicates
Ordering
Retry semantics
Batching
Throughput
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Async Defaults
Retry Behavior
Automatic retry twice
System defined delay
Discard if all retries fail. Unless ….
Dead Letter Queues (DLQ)
Send error events to an SQS queue or SNS topic
Turn this on!
Amazon SQS: Monitor via queue length metric or alarm
Amazon SNS: Send to persistent storage or reliable processor (e.g. error processing Lambda function)
Duplicates
At least once semantics. Be prepared for dupes.
Duplicates
Ordering
Retry semantics
Batching
Throughput
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon SQS
Automatically polled. Ordering not guaranteed.
At least once delivery
Set the right batch size
On success: All messages in batch deleted
On failure: All messages in batch returned to queue
Failed messages retried in subsequent batches
Set Dead-Letter Queue (redrive policy on SQS)
Partially succeeded batches: Delete successful
messages in your function
Producers: Horizontally scaled - nearly unlimited
TPS
Polling rate: f(Batch size, duration, concurrency)
Lambda
Function
SQS Queue
Duplicates
Ordering
Retry semantics
Batching
Throughput
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon SNS
Lambda
Function
Simple managed pub/sub
Fan out to multiple subscribers per topic - 10M+
Publish at tens of thousands of TPS
Ordering not guaranteed.
At least once delivery
Highly reliable delivery to Lambda
Amazon SNS will make 50 attempts over 13 hours before giving up
Retry: Default async behavior
One function invoke per message
SNS  SQS  Lambda if you want batches
SNS Topic
Duplicates
Ordering
Retry semantics
Batching
Throughput
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Concurrency
TPS ≠ Concurrency
Concurrency = TPS x Duration
Estimating - not straightforward
TPS, duration and distributions
Multiplying large numbers  chronic
overestimation
But then…. Don’t underestimate
Start: Peak TPS x Average Duration
Then load test to refine
Concurrency and Duration – CloudWatch
metrics
Account Limit vs Per-Function
Estimation by Paul Downey. Creative Commons License 2.0
Concurrency
Velocity
Duration
On success / failure
Transport vs Transform
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Per Function Concurrency
Limit ≠ Reservation
The difference is subtle but important
Maximum concurrency limit for that function
Protect scale-limited targets
Kill switch  Throttle down to 0
Reduces effective limit available for other functions
Prevent noisy neighbors in account
DO: Set on SLA-bound functions in your account
Predictable concurrency for functions on which configured
DO: Evaluate higher account limit if you need headroom
Concurrency
Velocity
Duration
On success / failure
Transport vs Transform
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Velocity
Know your application targets
Throughput goals
Event to processed latency
Scale behavior
Token bucket
Initial concurrency increase
Per minute increase
Slower Ramp – Application impact
Retry on throttles
Implement with back off
Concurrency
Velocity
Duration
On success / failure
Transport vs Transform
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Duration
Use code to transform not
transport
Batch size matters
15 minute functions
Optimum memory size
Controls CPU as well
>1.8 GB multi-core
Time = Money
Don’t spend $$$ just waiting
No orchestration in code
AWS Step Functions
Concurrency
Velocity
Duration
On success / failure
Transport vs Transform
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Maps, Search, Directions
420 million+ active users
Billions of requests per day
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Mapbox <3 Lambda
Early adopters of Lambda
• Stream processing
• Amazon API Gateway
• Amazon S3 notification events
• AWS CloudFormation custom resources
• Scheduled events
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lambda usage
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thinking in Lambda
Start with Lambda
Take on more operational work only as needed
Trade offs in overhead
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Logging processing
To have insight into the edge of our
API, we trigger ETL of Amazon
CloudFront logs as soon as they
arrive on Amazon S3.
These are used in tracking usage,
monitoring issues, planning &
analysis, and debugging.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon Athena
We need to be able to run
interactive queries over large
volume of logs.
Athena is a hosted PrestoDB
service, which allows you to write
SQL to query files on Amazon S3.
The speed and price of queries is
greatly impacted by how the data
structured and format its stored
in.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
CloudFront logs
Billions of request per day
20 TB+ of compressed request logs per month
Delivered to Amazon S3 in 1 path. gzip’d TSVs
Log volume varies a lot throughout the day with traffic. Hourly spikes of 3x.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Log Enrichment
Parse complex requests
Normalize values
Lookups (geoip, useragent,
etc)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Putting it together
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Deployment
Bundled by Lambda + AWS CodeBuild
AWS CloudFormation Lambda::Function
Amazon S3 notification event trigger
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Lambda code
99% business logic
Amazon S3 event on new
objects
Load file, parse, write to
Amazon S3
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
When stuff goes wrong
Retries
DLQ
Monitoring / Alarms
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Cost
Charged by 100ms * amount of memory.
Make function faster or use less memory.
Amount of memory also controls CPU.
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Scaling & Concurrency
Scaling done for you. Thanks AWS.
Concurrency is shared account wide.
Use concurrency reservations
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Caching
Lambda reuse the same node
process
(although no guarantees)
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon SQS
Concurrency, deal with event spikes
Retries / redrive policy (DLQ)
Control over batching
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Wrap up
Lambda scaling to the exact workload
Your code is focused on your business logic
Monitor and recover from failures
Control cost with memory and time
Easy deployment with AWS CodeBuild + AWS CloudFormation
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Thanks!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
In closing
Rich Serverless Service Portfolio
A world full of choices
Considerations for Event Generation,
Routing, and Processing
Choose the right tool for the job
Serverless pricing makes it easy
Iterate Fast: Try – Tweak – Deploy
AWS
SAM
Compliance
services
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Breakout repeats
Wednesday, November 26
Building Massively Parallel Event-Driven Architectures
6:15 pm – 7:15 pm | Venetian, Level 3, Murano 3205
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Related breakouts
Thursday, November 29
Leadership Session: Using DevOps, Microservices, and Serverless
to Accelerate Innovation (SRV325)
12:15 – 1:15 PM | Venetian Theatre (Level 2)
Thank you!
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amit Kulkarni
amikul@amazon.com
@kulkarni_amit
Mick Thompson
mick@mapbox.com
© 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.

More Related Content

What's hot

What's hot (20)

Building Well Architected .NET Apps (WIN304) - AWS re:Invent 2018
Building Well Architected .NET Apps (WIN304) - AWS re:Invent 2018Building Well Architected .NET Apps (WIN304) - AWS re:Invent 2018
Building Well Architected .NET Apps (WIN304) - AWS re:Invent 2018
 
Architecting Next Generation Serverless SaaS Solutions on AWS (ARC324-R1) - A...
Architecting Next Generation Serverless SaaS Solutions on AWS (ARC324-R1) - A...Architecting Next Generation Serverless SaaS Solutions on AWS (ARC324-R1) - A...
Architecting Next Generation Serverless SaaS Solutions on AWS (ARC324-R1) - A...
 
High Velocity DevOps: Four Ways to Leverage CloudFront in Faster DevOps Workf...
High Velocity DevOps: Four Ways to Leverage CloudFront in Faster DevOps Workf...High Velocity DevOps: Four Ways to Leverage CloudFront in Faster DevOps Workf...
High Velocity DevOps: Four Ways to Leverage CloudFront in Faster DevOps Workf...
 
Serverless:It All Started in Vegas (DVC306) - AWS re:Invent 2018
Serverless:It All Started in Vegas (DVC306) - AWS re:Invent 2018Serverless:It All Started in Vegas (DVC306) - AWS re:Invent 2018
Serverless:It All Started in Vegas (DVC306) - AWS re:Invent 2018
 
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
Introducing AWS Transfer for SFTP, a Fully Managed SFTP Service for Amazon S3...
 
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
[NEW LAUNCH!] AWS Transit Gateway and Transit VPCs - Reference Architectures ...
 
Moving to DevOps the Amazon Way (DEV210-R1) - AWS re:Invent 2018
Moving to DevOps the Amazon Way (DEV210-R1) - AWS re:Invent 2018Moving to DevOps the Amazon Way (DEV210-R1) - AWS re:Invent 2018
Moving to DevOps the Amazon Way (DEV210-R1) - AWS re:Invent 2018
 
Industrialize Machine Learning Using CI/CD Techniques (FSV304-i) - AWS re:Inv...
Industrialize Machine Learning Using CI/CD Techniques (FSV304-i) - AWS re:Inv...Industrialize Machine Learning Using CI/CD Techniques (FSV304-i) - AWS re:Inv...
Industrialize Machine Learning Using CI/CD Techniques (FSV304-i) - AWS re:Inv...
 
SRV207 Orchestrating AWS Lambda with Step Functions
 SRV207 Orchestrating AWS Lambda with Step Functions SRV207 Orchestrating AWS Lambda with Step Functions
SRV207 Orchestrating AWS Lambda with Step Functions
 
Optimize Amazon EC2 for Fun and Profit
Optimize Amazon EC2 for Fun and Profit Optimize Amazon EC2 for Fun and Profit
Optimize Amazon EC2 for Fun and Profit
 
Serverless Stream Processing Tips & Tricks (ANT358) - AWS re:Invent 2018
Serverless Stream Processing Tips & Tricks (ANT358) - AWS re:Invent 2018Serverless Stream Processing Tips & Tricks (ANT358) - AWS re:Invent 2018
Serverless Stream Processing Tips & Tricks (ANT358) - AWS re:Invent 2018
 
Amazon Redshift 與 Amazon Redshift Spectrum 幫您建立現代化資料倉儲 (Level 300)
Amazon Redshift 與 Amazon Redshift Spectrum 幫您建立現代化資料倉儲 (Level 300)Amazon Redshift 與 Amazon Redshift Spectrum 幫您建立現代化資料倉儲 (Level 300)
Amazon Redshift 與 Amazon Redshift Spectrum 幫您建立現代化資料倉儲 (Level 300)
 
Multi-Account Strategy and Security with Centrica Hive
Multi-Account Strategy and Security with Centrica HiveMulti-Account Strategy and Security with Centrica Hive
Multi-Account Strategy and Security with Centrica Hive
 
From One to Many: Diving Deeper into Evolving VPC Design (ARC310-R2) - AWS re...
From One to Many: Diving Deeper into Evolving VPC Design (ARC310-R2) - AWS re...From One to Many: Diving Deeper into Evolving VPC Design (ARC310-R2) - AWS re...
From One to Many: Diving Deeper into Evolving VPC Design (ARC310-R2) - AWS re...
 
Secure your AWS Account and your Organization's Accounts
Secure your AWS Account and your Organization's Accounts Secure your AWS Account and your Organization's Accounts
Secure your AWS Account and your Organization's Accounts
 
Threat Detection and Mitigation at Scale on AWS
Threat Detection and Mitigation at Scale on AWS Threat Detection and Mitigation at Scale on AWS
Threat Detection and Mitigation at Scale on AWS
 
善用 GraphQL 與 AWS AppSync 讓您的 Progressive Web App (PWA) 加速進化 (Level 200)
善用  GraphQL 與 AWS AppSync 讓您的  Progressive Web App (PWA) 加速進化 (Level 200)善用  GraphQL 與 AWS AppSync 讓您的  Progressive Web App (PWA) 加速進化 (Level 200)
善用 GraphQL 與 AWS AppSync 讓您的 Progressive Web App (PWA) 加速進化 (Level 200)
 
Don’t Let SFTP Weigh Down Your Migration to the Cloud (STG381-R1) - AWS re:In...
Don’t Let SFTP Weigh Down Your Migration to the Cloud (STG381-R1) - AWS re:In...Don’t Let SFTP Weigh Down Your Migration to the Cloud (STG381-R1) - AWS re:In...
Don’t Let SFTP Weigh Down Your Migration to the Cloud (STG381-R1) - AWS re:In...
 
Amazon VPC: Security at the Speed Of Light (NET313) - AWS re:Invent 2018
Amazon VPC: Security at the Speed Of Light (NET313) - AWS re:Invent 2018Amazon VPC: Security at the Speed Of Light (NET313) - AWS re:Invent 2018
Amazon VPC: Security at the Speed Of Light (NET313) - AWS re:Invent 2018
 
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
Building Serverless Applications Using AWS AppSync and Amazon Neptune (SRV307...
 

Similar to Building Massively Parallel Event-Driven Architectures (SRV373-R1) - AWS re:Invent 2018

Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Amazon Web Services
 

Similar to Building Massively Parallel Event-Driven Architectures (SRV373-R1) - AWS re:Invent 2018 (20)

Serverless Architectural Patterns - GOTO Amsterdam
Serverless Architectural Patterns - GOTO AmsterdamServerless Architectural Patterns - GOTO Amsterdam
Serverless Architectural Patterns - GOTO Amsterdam
 
How can your business benefit from going Serverless
How can your business benefit from going ServerlessHow can your business benefit from going Serverless
How can your business benefit from going Serverless
 
How can your business benefit from going serverless?
How can your business benefit from going serverless?How can your business benefit from going serverless?
How can your business benefit from going serverless?
 
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
Getting Started with Serverless Architectures with Microservices_AWSPSSummit_...
 
Shift-Left SRE: Self-Healing with AWS Lambda Functions (DEV313-S) - AWS re:In...
Shift-Left SRE: Self-Healing with AWS Lambda Functions (DEV313-S) - AWS re:In...Shift-Left SRE: Self-Healing with AWS Lambda Functions (DEV313-S) - AWS re:In...
Shift-Left SRE: Self-Healing with AWS Lambda Functions (DEV313-S) - AWS re:In...
 
Inside AWS: Technology Choices for Modern Applications (SRV305-R1) - AWS re:I...
Inside AWS: Technology Choices for Modern Applications (SRV305-R1) - AWS re:I...Inside AWS: Technology Choices for Modern Applications (SRV305-R1) - AWS re:I...
Inside AWS: Technology Choices for Modern Applications (SRV305-R1) - AWS re:I...
 
Serverless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best PracticesServerless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best Practices
 
Coordinating Microservices with AWS Step Functions.pdf
Coordinating Microservices with AWS Step Functions.pdfCoordinating Microservices with AWS Step Functions.pdf
Coordinating Microservices with AWS Step Functions.pdf
 
ServerlessConf 2018 Keynote - Debunking Serverless Myths
ServerlessConf 2018 Keynote - Debunking Serverless MythsServerlessConf 2018 Keynote - Debunking Serverless Myths
ServerlessConf 2018 Keynote - Debunking Serverless Myths
 
Serverless Architectural Patterns - ServerlessDays TLV
Serverless Architectural Patterns - ServerlessDays TLVServerless Architectural Patterns - ServerlessDays TLV
Serverless Architectural Patterns - ServerlessDays TLV
 
Architecting for Real-Time Insights with Amazon Kinesis (ANT310) - AWS re:Inv...
Architecting for Real-Time Insights with Amazon Kinesis (ANT310) - AWS re:Inv...Architecting for Real-Time Insights with Amazon Kinesis (ANT310) - AWS re:Inv...
Architecting for Real-Time Insights with Amazon Kinesis (ANT310) - AWS re:Inv...
 
Vonage & Aspect: Transform Real-Time Communications & Customer Engagement (TL...
Vonage & Aspect: Transform Real-Time Communications & Customer Engagement (TL...Vonage & Aspect: Transform Real-Time Communications & Customer Engagement (TL...
Vonage & Aspect: Transform Real-Time Communications & Customer Engagement (TL...
 
Serverless Stream Processing Pipeline Best Practices (SRV316-R1) - AWS re:Inv...
Serverless Stream Processing Pipeline Best Practices (SRV316-R1) - AWS re:Inv...Serverless Stream Processing Pipeline Best Practices (SRV316-R1) - AWS re:Inv...
Serverless Stream Processing Pipeline Best Practices (SRV316-R1) - AWS re:Inv...
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
SRV316 Serverless Data Processing at Scale: An Amazon.com Case Study
 SRV316 Serverless Data Processing at Scale: An Amazon.com Case Study SRV316 Serverless Data Processing at Scale: An Amazon.com Case Study
SRV316 Serverless Data Processing at Scale: An Amazon.com Case Study
 
AWS IoT for Frictionless Consumer Experiences in Retail (RET201) - AWS re:Inv...
AWS IoT for Frictionless Consumer Experiences in Retail (RET201) - AWS re:Inv...AWS IoT for Frictionless Consumer Experiences in Retail (RET201) - AWS re:Inv...
AWS IoT for Frictionless Consumer Experiences in Retail (RET201) - AWS re:Inv...
 
Lock it Down: How to Secure your AWS Account and your Organization's Accounts
Lock it Down: How to Secure your AWS Account and your Organization's AccountsLock it Down: How to Secure your AWS Account and your Organization's Accounts
Lock it Down: How to Secure your AWS Account and your Organization's Accounts
 
Serverless Streams, Topics, Queues, & APIs! Pick the Right Serverless Applica...
Serverless Streams, Topics, Queues, & APIs! Pick the Right Serverless Applica...Serverless Streams, Topics, Queues, & APIs! Pick the Right Serverless Applica...
Serverless Streams, Topics, Queues, & APIs! Pick the Right Serverless Applica...
 
Build Your Own Log Analytics Solutions on AWS (ANT323-R) - AWS re:Invent 2018
Build Your Own Log Analytics Solutions on AWS (ANT323-R) - AWS re:Invent 2018Build Your Own Log Analytics Solutions on AWS (ANT323-R) - AWS re:Invent 2018
Build Your Own Log Analytics Solutions on AWS (ANT323-R) - AWS re:Invent 2018
 
Accelerate Analytics at Scale with Amazon EMR - AWS Summit Sydney 2018
Accelerate Analytics at Scale with Amazon EMR - AWS Summit Sydney 2018Accelerate Analytics at Scale with Amazon EMR - AWS Summit Sydney 2018
Accelerate Analytics at Scale with Amazon EMR - AWS Summit Sydney 2018
 

More from Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Building Massively Parallel Event-Driven Architectures (SRV373-R1) - AWS re:Invent 2018

  • 1.
  • 2. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Building Massively Parallel Event- Driven Architectures Amit Kulkarni Principal Product Manager AWS Serverless S R V 3 7 3 - R Mick Thompson Data Engineer Mapbox
  • 3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Agenda Modern Serverless Applications Event Delivery Concepts Event Generation, Routing, and Processing Real World High Scale Serverless Application Wrap
  • 4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. THE SERVERLESS OPERATIONAL MODEL No provisioning, no management Pay for value Automatic scaling Highly available and secure
  • 5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. processes 4,000 requests per second ingests, analyzes and stores 17+ petabytes of data per season processes half a trillion validations of stock trades daily executes 16 million requests a month processes tens of billions of data points monthly SERVERLESS AT SCALE IS THE NEW NORM API traffic to register and license more than 47 million driver records in Great Britain.
  • 6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. High scale and resiliency at very low cost Financial Engines AWS Lambda to power the core of its computational “engines” which automate portfolio management combined with access to human advisors. Benefits of AWS Serverless • Handles 200–300 million server requests per month at rates of up to 60,000 per minute • Reduced infrastructure costs by more than 90 percent • Zero server downtime Using AWS Lambda will enable us to scale to serve millions more who need financial help. Paul Gibson Principal System Architect
  • 7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state EVENT SOURCE FUNCTION Node.js Python Java C# Go PowerShell Event-Driven Architecture
  • 8. To grow really big in the future, you need to think big now!
  • 9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Core Concepts Event Generation Event Routing Event Processing Output Getting the event details to processor Emitting information about the event Take action on the event
  • 11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Delivery – AWS Services Event Generation Event Routing Event Processing Output
  • 12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Key Considerations Event Generation Event Routing Event Processing Output Payload Persistence Duplicates Ordering Retry semantics Batching Throughput Concurrency Velocity Duration On success / failure Transport vs. Transform Cost $$$
  • 13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. How do I choose? If you know your enemies and know yourself, you will not be imperiled in a hundred battles. - Sun Tzu, The Art of War
  • 14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Payload potential_customer = { "name":"John", "age":30, "cars": { "car1":"Ford", "car2":"BMW", "car3":"Fiat" } } Payload Persistence
  • 16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Event Persistence Availability Events accessible even if source is down Retention Events accessible till processed Cost Storage, data transfer, and access Complexity Dependency, operational, scale Payload Persistence
  • 17. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. No routing / default routing Lambda Function Synchronous Request-Response Immediate access to results You manage: - Retries - Ordering - Error Handling - Blocking and Threads - Timeouts Asynchronous Fire (and forget) Default behavior - Retries - Ordering - DLQ errors - Throughput You manage: - Error Response - Duplicates Lambda Function S3 bucket Duplicates Ordering Retry semantics Batching Throughput
  • 19. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Async Defaults Retry Behavior Automatic retry twice System defined delay Discard if all retries fail. Unless …. Dead Letter Queues (DLQ) Send error events to an SQS queue or SNS topic Turn this on! Amazon SQS: Monitor via queue length metric or alarm Amazon SNS: Send to persistent storage or reliable processor (e.g. error processing Lambda function) Duplicates At least once semantics. Be prepared for dupes. Duplicates Ordering Retry semantics Batching Throughput
  • 20. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon SQS Automatically polled. Ordering not guaranteed. At least once delivery Set the right batch size On success: All messages in batch deleted On failure: All messages in batch returned to queue Failed messages retried in subsequent batches Set Dead-Letter Queue (redrive policy on SQS) Partially succeeded batches: Delete successful messages in your function Producers: Horizontally scaled - nearly unlimited TPS Polling rate: f(Batch size, duration, concurrency) Lambda Function SQS Queue Duplicates Ordering Retry semantics Batching Throughput
  • 21. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon SNS Lambda Function Simple managed pub/sub Fan out to multiple subscribers per topic - 10M+ Publish at tens of thousands of TPS Ordering not guaranteed. At least once delivery Highly reliable delivery to Lambda Amazon SNS will make 50 attempts over 13 hours before giving up Retry: Default async behavior One function invoke per message SNS  SQS  Lambda if you want batches SNS Topic Duplicates Ordering Retry semantics Batching Throughput
  • 22. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 23. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Concurrency TPS ≠ Concurrency Concurrency = TPS x Duration Estimating - not straightforward TPS, duration and distributions Multiplying large numbers  chronic overestimation But then…. Don’t underestimate Start: Peak TPS x Average Duration Then load test to refine Concurrency and Duration – CloudWatch metrics Account Limit vs Per-Function Estimation by Paul Downey. Creative Commons License 2.0 Concurrency Velocity Duration On success / failure Transport vs Transform
  • 24. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Per Function Concurrency Limit ≠ Reservation The difference is subtle but important Maximum concurrency limit for that function Protect scale-limited targets Kill switch  Throttle down to 0 Reduces effective limit available for other functions Prevent noisy neighbors in account DO: Set on SLA-bound functions in your account Predictable concurrency for functions on which configured DO: Evaluate higher account limit if you need headroom Concurrency Velocity Duration On success / failure Transport vs Transform
  • 25. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Velocity Know your application targets Throughput goals Event to processed latency Scale behavior Token bucket Initial concurrency increase Per minute increase Slower Ramp – Application impact Retry on throttles Implement with back off Concurrency Velocity Duration On success / failure Transport vs Transform
  • 26. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Duration Use code to transform not transport Batch size matters 15 minute functions Optimum memory size Controls CPU as well >1.8 GB multi-core Time = Money Don’t spend $$$ just waiting No orchestration in code AWS Step Functions Concurrency Velocity Duration On success / failure Transport vs Transform
  • 27. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 28. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 29. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Maps, Search, Directions 420 million+ active users Billions of requests per day
  • 30. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Mapbox <3 Lambda Early adopters of Lambda • Stream processing • Amazon API Gateway • Amazon S3 notification events • AWS CloudFormation custom resources • Scheduled events
  • 31. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lambda usage
  • 32. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thinking in Lambda Start with Lambda Take on more operational work only as needed Trade offs in overhead
  • 33. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Logging processing To have insight into the edge of our API, we trigger ETL of Amazon CloudFront logs as soon as they arrive on Amazon S3. These are used in tracking usage, monitoring issues, planning & analysis, and debugging.
  • 34. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon Athena We need to be able to run interactive queries over large volume of logs. Athena is a hosted PrestoDB service, which allows you to write SQL to query files on Amazon S3. The speed and price of queries is greatly impacted by how the data structured and format its stored in.
  • 35. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. CloudFront logs Billions of request per day 20 TB+ of compressed request logs per month Delivered to Amazon S3 in 1 path. gzip’d TSVs Log volume varies a lot throughout the day with traffic. Hourly spikes of 3x.
  • 36. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Log Enrichment Parse complex requests Normalize values Lookups (geoip, useragent, etc)
  • 37. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Putting it together
  • 38. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Deployment Bundled by Lambda + AWS CodeBuild AWS CloudFormation Lambda::Function Amazon S3 notification event trigger
  • 39. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Lambda code 99% business logic Amazon S3 event on new objects Load file, parse, write to Amazon S3
  • 40. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. When stuff goes wrong Retries DLQ Monitoring / Alarms
  • 41. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Cost Charged by 100ms * amount of memory. Make function faster or use less memory. Amount of memory also controls CPU.
  • 42. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Scaling & Concurrency Scaling done for you. Thanks AWS. Concurrency is shared account wide. Use concurrency reservations
  • 43. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Caching Lambda reuse the same node process (although no guarantees)
  • 44. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amazon SQS Concurrency, deal with event spikes Retries / redrive policy (DLQ) Control over batching
  • 45. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Wrap up Lambda scaling to the exact workload Your code is focused on your business logic Monitor and recover from failures Control cost with memory and time Easy deployment with AWS CodeBuild + AWS CloudFormation
  • 46. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Thanks!
  • 47. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. In closing Rich Serverless Service Portfolio A world full of choices Considerations for Event Generation, Routing, and Processing Choose the right tool for the job Serverless pricing makes it easy Iterate Fast: Try – Tweak – Deploy AWS SAM Compliance services
  • 48. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Breakout repeats Wednesday, November 26 Building Massively Parallel Event-Driven Architectures 6:15 pm – 7:15 pm | Venetian, Level 3, Murano 3205
  • 49. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Related breakouts Thursday, November 29 Leadership Session: Using DevOps, Microservices, and Serverless to Accelerate Innovation (SRV325) 12:15 – 1:15 PM | Venetian Theatre (Level 2)
  • 50. Thank you! © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved. Amit Kulkarni amikul@amazon.com @kulkarni_amit Mick Thompson mick@mapbox.com
  • 51. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.