SlideShare a Scribd company logo
1 of 44
© 2020, Amazon Web Services, Inc. or its Affiliates.
Controls for Managing Events in
Serverless Applications
Ben Smith
Senior Developer Advocate, AWS Serverless
@benjamin_l_s
© 2020, Amazon Web Services, Inc. or its Affiliates.
Agenda
Asynchronous invocations controls
Stream processing invocation controls
© 2020, Amazon Web Services, Inc. or its Affiliates.
Monoliths and microservices
Monolith
Does everything
Microservices
Does one thing
© 2020, Amazon Web Services, Inc. or its Affiliates.
The end goal
And do it faster
© 2020, Amazon Web Services, Inc. or its Affiliates.
Architecture v1
This is fine for a simple command orientated design
© 2020, Amazon Web Services, Inc. or its Affiliates.
Architecture v2
But the Order service needs additional logic
for each additional downstream service
© 2020, Amazon Web Services, Inc. or its Affiliates.
Long-term architecture
The Order service soon becomes a blocker
when integrating new services
© 2020, Amazon Web Services, Inc. or its Affiliates.
Events to the rescue
© 2020, Amazon Web Services, Inc. or its Affiliates.
[i-’vent]
© 2020, Amazon Web Services, Inc. or its Affiliates.
Events are observable, not directed
© 2020, Amazon Web Services, Inc. or its Affiliates.
Long-term architecture
Hooking services together this way
Prevents teams from moving fast
© 2020, Amazon Web Services, Inc. or its Affiliates.
Event routers for fan out
Event router
Router determines which downstream
systems receive each event
© 2020, Amazon Web Services, Inc. or its Affiliates.
Amazon EventBridge
schema registry
© 2020, Amazon Web Services, Inc. or its Affiliates.
A serverless event bus service for
SaaS and AWS services
• Fully managed, pay-as-you-go
• Native integration with SaaS
providers
• 17 target services
• Easily build event-driven
architectures
© 2020, Amazon Web Services, Inc. or its Affiliates.
• Source of truth for sharing
schema
• Explicitly published and auto-
discovered
• Integrations forVS Code and
JetBrains
• Language bindings for Java,
Python, andTypeScript
Schema registry
© 2020, Amazon Web Services, Inc. or its Affiliates.
Serverless
© 2020, Amazon Web Services, Inc. or its Affiliates.
What is serverless?
No infrastructure provisioning,
no management
Automatic scaling
Pay for value Highly available and secure
© 2020, Amazon Web Services, Inc. or its Affiliates.
Event-driven compute
Functions as a service
Serverless FaaS
© 2020, Amazon Web Services, Inc. or its Affiliates.
Serverless applications
Event source / invocation Services
Changes in
data state
Requests to
endpoints
Changes in
Resource state
Function
Node.js
Python
Java
C#
Go
Ruby
Runtime API
© 2020, Amazon Web Services, Inc. or its Affiliates.
Lambda execution model
Synchronous (push) Asynchronous (event) Stream
(Poll-based)
Amazon
DynamoDB
Amazon
SNS
/order
Amazon
S3
reqs
Amazon
Kinesis
changes
AWS Lambda
service
Amazon API
Gateway
Lambda
function
Lambda
function
function
© 2020, Amazon Web Services, Inc. or its Affiliates.
Asynchronous Invocations
© 2020, Amazon Web Services, Inc. or its Affiliates.
Async under
the hood
• Lambda polls one event at a time and invokes a function
• Lambda only deletes a message/request after processing successfully
Events Event Queue Lambda function
© 2020, Amazon Web Services, Inc. or its Affiliates.
What could
possibly go
wrong?
• Function errors, retried twice
• Throttling and system errors, retried for
up to six hours
• Duplicated processing
© 2020, Amazon Web Services, Inc. or its Affiliates.
When retries
are not
meaningful
Use these new controls:
• Event age
(Default/Maximum: 6 hours, Minimum:
60s)
• Retry attempts
(Default/Maximum: 2, Minimum: 0)
© 2020, Amazon Web Services, Inc. or its Affiliates.
How to
configure?
In the AWS Management Console
Using the AWS Serverless Application Model (SAM)
© 2020, Amazon Web Services, Inc. or its Affiliates.
Async under the
hood
• Lambda returns 2xx status code to confirm event received
Events Event Queue Lambda function
202 response
© 2020, Amazon Web Services, Inc. or its Affiliates.
Do more with
less code
using Lambda
Destinations
Lambda
SNS
SQS
EventBridge
Lambda
Success/Failure
"version":
"timestamp":
"requestContext": {
"requestId":
"functionArn":
"condition":
"approximateInvokeCount”:},
"requestPayload": {}, "responseContext": {
"statusCode": "executedVersion":},
"responsePayload": {}
Execution Result being sent to
downstream
© 2020, Amazon Web Services, Inc. or its Affiliates.
Before
Lambda
Destinations
Response
Total running time ms
Idle running time
Idle running time
Synchronous Lambda chaining means paying for
Idle wait times.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Lambda
Destinations
On Success
Response
Total running time ms
Using Lambda Destinations OnSuccess, you can
chain functions asynchronously without paying for
idle wait time.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Lambda
Destinations
On Failure
S3 Identify EventBridge
SQS
S3
S3
Transform
Transform
Process Error
On Failure
Handle function failures without coding extra logic
using Lambda Destinations OnFailure.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Use
Destinations
for:
• Building simple workflow by chaining
Lambda functions
• Handling failures with additional context
• Visibility and notification using
EventBridge or SNS
• Batching events to process with SQS or
EventBridge
© 2020, Amazon Web Services, Inc. or its Affiliates.
Things to
know…
• Lambda execution role must have
permission to access the destination
service.
• Execution result size shouldn’t exceed
the payload size limit of downstream
services
• On-failure destination delivers more
context than dead-letter queue.
© 2020, Amazon Web Services, Inc. or its Affiliates.
How to
configure?
In the AWS Management Console
Using the AWS SAM
© 2020, Amazon Web Services, Inc. or its Affiliates.
Stream processing invocations
(from Amazon Kinesis and Amazon DynamoDB)
© 2020, Amazon Web Services, Inc. or its Affiliates.
Processing
Kinesis/
DynamoDB
data streams
Data Streams
shard 1
shard 2
shard 3
shard 4
Data
Producer
Lambda as Data Consumer
functionA
(instance 1)
functionA
(instance 2)
functionA
(instance 3)
functionA
(instance 4)
• By default Lambda processes one batch at a time per shard
• Max concurrency = number of shards
© 2020, Amazon Web Services, Inc. or its Affiliates.
Sparse data off
peak
• By default, Lambda poller fetches data every second
• Could result in batches with sparse data
1 second poller window
© 2020, Amazon Web Services, Inc. or its Affiliates.
Dealing with
sparse data off
peak with
Batch Window
• Batch Window allows to batch up to 300s before invocation.
• New invocation criteria: 6MB payload, Maximum Batch
Window, Maximum Batch Size
Wait up to 300 seconds
© 2020, Amazon Web Services, Inc. or its Affiliates.
Dealing with
data spikes with
Parallelization
Factor
• Parallelization Factor (PF) allows you to have up to 10
batches per shard. Order is guaranteed at partition key
level.
• Faster stream processing without over-scaling
Amazon Kinesis
Shard
1213
Record
Processor
Consistent hashing
1
2
1
3
Batcher 1
Batcher 2
Batcher 3
--parallelization-factor 3
© 2020, Amazon Web Services, Inc. or its Affiliates.
Failures on
stream
processing
• Malformed data leads to stuck shard
and infinite (~10000) retries.
• Records are always retried in batches,
which made it hard to identify the bad
record.
• 1 malformed record can block the entire
stream, the “poison pill”
© 2020, Amazon Web Services, Inc. or its Affiliates.
No more
stuck shards
• Skip processing old records using
MaximumRecordAgeInSeconds (60s to 7 days).
• Specify how many retries on a record with
MaximumRetryAttempts (0 to 10,000).
• Send metadata of failed records to SNS/SQS
using on-failure destination.
© 2020, Amazon Web Services, Inc. or its Affiliates.
Trace down
the bad
record with
Bisect On
Function Error
Batch size = 9, Bisect = true, MaxRetryAttempt = 1
on-failure destination configured
1st invoke
2nd invoke
3rd invoke
4th invoke
Error, Request ID 1, Retry = 0
5th invoke
6th invoke
7th invoke
Error, Request ID 2, Retry = 0
Success, Request ID 3, Retry = 0
Error, Request ID 4, Retry = 0
Success, Request ID 5, Retry = 0
Error, Request ID 6, Retry = 0
Error, Request ID 6, Retry = 1, sent
to on-failure destination
Record 1 -> 9
8th invoke Success, Request ID 7, Retry = 0
© 2020, Amazon Web Services, Inc. or its Affiliates.
Setting the new stream processing controls
© 2020, Amazon Web Services, Inc. or its Affiliates.
Summary
Asynchronous Invocations
Manage event schemas with
Schema Registry
Schema Discovery
Manage retries with
MaximumEventAgeInSeconds
MaximumRetryAttempts
Do more with less code
Lambda Destinations
OnSuccess
OnFailure
Stream Processing Invocations
Handle sparse data with
Batch Window
Handle spikes with
Parallelization Factor
Eliminate ”poison pill” with
BisectOnFunctionError
Manage failures with
MaximumRecordAgeInSeconds
MaximumRetryAttempts
OnFailureDestination
Use these new controls to manage events in your serverless applications
© 2020, Amazon Web Services, Inc. or its Affiliates.
Thank you
Ben Smith
Senior Developer Advocate, AWS Serverless
@benjamin_l_s

More Related Content

What's hot

Introduction to the Serverless Cloud
Introduction to the Serverless CloudIntroduction to the Serverless Cloud
Introduction to the Serverless CloudAmazon Web Services
 
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...Chris Munns
 
AWS Transit Gateway-Benefits and Best Practices
AWS Transit Gateway-Benefits and Best PracticesAWS Transit Gateway-Benefits and Best Practices
AWS Transit Gateway-Benefits and Best PracticesJohn Varghese
 
Getting Started with Containers on AWS: Collision 2018
Getting Started with Containers on AWS: Collision 2018Getting Started with Containers on AWS: Collision 2018
Getting Started with Containers on AWS: Collision 2018Amazon Web Services
 
Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28Boaz Ziniman
 
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver Vanker
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver VankerAWS reinvent 2019 recap - Riyadh - Network and Security - Anver Vanker
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver VankerAWS Riyadh User Group
 
Orchestrating AWS Lambda with AWS Step Functions
Orchestrating AWS Lambda with AWS Step Functions Orchestrating AWS Lambda with AWS Step Functions
Orchestrating AWS Lambda with AWS Step Functions Amazon Web Services
 
Serverless Applications with AWS SAM
Serverless Applications with AWS SAMServerless Applications with AWS SAM
Serverless Applications with AWS SAMChris Munns
 
VMware Cloud on AWS - Technical Deep Dive - AWS Summit Sydney
VMware Cloud on AWS - Technical Deep Dive - AWS Summit SydneyVMware Cloud on AWS - Technical Deep Dive - AWS Summit Sydney
VMware Cloud on AWS - Technical Deep Dive - AWS Summit SydneyAmazon Web Services
 
Networking Best Practices for Your Serverless Applications
Networking Best Practices for Your Serverless ApplicationsNetworking Best Practices for Your Serverless Applications
Networking Best Practices for Your Serverless ApplicationsChris Munns
 
Getting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless ComputingGetting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless ComputingAmazon Web Services
 
Security at Scale with AWS - AWS Summit Cape Town 2017
Security at Scale with AWS - AWS Summit Cape Town 2017 Security at Scale with AWS - AWS Summit Cape Town 2017
Security at Scale with AWS - AWS Summit Cape Town 2017 Amazon Web Services
 
Serverless Architecture 101 ⚡
Serverless Architecture 101 ⚡Serverless Architecture 101 ⚡
Serverless Architecture 101 ⚡Thanh Nguyen
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)Amazon Web Services
 
Data Design and Modeling for Microservices I AWS Dev Day 2018
Data Design and Modeling for Microservices I AWS Dev Day 2018Data Design and Modeling for Microservices I AWS Dev Day 2018
Data Design and Modeling for Microservices I AWS Dev Day 2018AWS Germany
 
Moving your commercial databases to Amazon RDS
Moving your commercial databases to Amazon RDSMoving your commercial databases to Amazon RDS
Moving your commercial databases to Amazon RDSAmazon Web Services
 
Working with microservices and Amazon ECS at Airtime
Working with microservices and Amazon ECS at AirtimeWorking with microservices and Amazon ECS at Airtime
Working with microservices and Amazon ECS at AirtimeAmazon Web Services
 
Continuous Delivery to Amazon ECS
Continuous Delivery to Amazon ECS Continuous Delivery to Amazon ECS
Continuous Delivery to Amazon ECS Amazon Web Services
 

What's hot (20)

Introduction to the Serverless Cloud
Introduction to the Serverless CloudIntroduction to the Serverless Cloud
Introduction to the Serverless Cloud
 
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
Gluecon 2018 - The Best Practices and Hard Lessons Learned of Serverless Appl...
 
AWS Transit Gateway-Benefits and Best Practices
AWS Transit Gateway-Benefits and Best PracticesAWS Transit Gateway-Benefits and Best Practices
AWS Transit Gateway-Benefits and Best Practices
 
Getting Started with Containers on AWS: Collision 2018
Getting Started with Containers on AWS: Collision 2018Getting Started with Containers on AWS: Collision 2018
Getting Started with Containers on AWS: Collision 2018
 
Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28
 
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver Vanker
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver VankerAWS reinvent 2019 recap - Riyadh - Network and Security - Anver Vanker
AWS reinvent 2019 recap - Riyadh - Network and Security - Anver Vanker
 
Demistifying serverless on aws
Demistifying serverless on awsDemistifying serverless on aws
Demistifying serverless on aws
 
Orchestrating AWS Lambda with AWS Step Functions
Orchestrating AWS Lambda with AWS Step Functions Orchestrating AWS Lambda with AWS Step Functions
Orchestrating AWS Lambda with AWS Step Functions
 
Serverless Applications with AWS SAM
Serverless Applications with AWS SAMServerless Applications with AWS SAM
Serverless Applications with AWS SAM
 
VMware Cloud on AWS - Technical Deep Dive - AWS Summit Sydney
VMware Cloud on AWS - Technical Deep Dive - AWS Summit SydneyVMware Cloud on AWS - Technical Deep Dive - AWS Summit Sydney
VMware Cloud on AWS - Technical Deep Dive - AWS Summit Sydney
 
Networking Best Practices for Your Serverless Applications
Networking Best Practices for Your Serverless ApplicationsNetworking Best Practices for Your Serverless Applications
Networking Best Practices for Your Serverless Applications
 
Getting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless ComputingGetting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless Computing
 
Security at Scale with AWS - AWS Summit Cape Town 2017
Security at Scale with AWS - AWS Summit Cape Town 2017 Security at Scale with AWS - AWS Summit Cape Town 2017
Security at Scale with AWS - AWS Summit Cape Town 2017
 
Serverless Architecture 101 ⚡
Serverless Architecture 101 ⚡Serverless Architecture 101 ⚡
Serverless Architecture 101 ⚡
 
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
AWS re:Invent 2016: Building Complex Serverless Applications (GPST404)
 
Data Design and Modeling for Microservices I AWS Dev Day 2018
Data Design and Modeling for Microservices I AWS Dev Day 2018Data Design and Modeling for Microservices I AWS Dev Day 2018
Data Design and Modeling for Microservices I AWS Dev Day 2018
 
Moving your commercial databases to Amazon RDS
Moving your commercial databases to Amazon RDSMoving your commercial databases to Amazon RDS
Moving your commercial databases to Amazon RDS
 
Working with microservices and Amazon ECS at Airtime
Working with microservices and Amazon ECS at AirtimeWorking with microservices and Amazon ECS at Airtime
Working with microservices and Amazon ECS at Airtime
 
Continuous Delivery to Amazon ECS
Continuous Delivery to Amazon ECS Continuous Delivery to Amazon ECS
Continuous Delivery to Amazon ECS
 
Deep Dive into Amazon Fargate
Deep Dive into Amazon FargateDeep Dive into Amazon Fargate
Deep Dive into Amazon Fargate
 

Similar to AWS re:Invent serverless recap day: Controls for-managing-events-in-serverless-applications

Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesRohini Gaonkar
 
Getting started building your first serverless web application on AWS
Getting started building  your first serverless web application on AWSGetting started building  your first serverless web application on AWS
Getting started building your first serverless web application on AWSIoannis Polyzos
 
Serverless AWS reInvent 2019 recap
Serverless AWS reInvent 2019 recapServerless AWS reInvent 2019 recap
Serverless AWS reInvent 2019 recapDaniel Zivkovic
 
Keynote Gregor Hohpe - Serverless Architectures
Keynote Gregor Hohpe - Serverless ArchitecturesKeynote Gregor Hohpe - Serverless Architectures
Keynote Gregor Hohpe - Serverless ArchitecturesBATbern
 
AWSome Day Online 2020_Modul 3: Membangun di Cloud
AWSome Day Online 2020_Modul 3: Membangun di CloudAWSome Day Online 2020_Modul 3: Membangun di Cloud
AWSome Day Online 2020_Modul 3: Membangun di CloudAmazon Web Services
 
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程Amazon Web Services
 
Leveraging serverless in fullstack development
Leveraging serverless in fullstack developmentLeveraging serverless in fullstack development
Leveraging serverless in fullstack developmentEric Johnson
 
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS Cloud
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS CloudAWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS Cloud
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS CloudAmazon Web Services
 
Building real-time serverless data applications with Confluent and AWS - Lond...
Building real-time serverless data applications with Confluent and AWS - Lond...Building real-time serverless data applications with Confluent and AWS - Lond...
Building real-time serverless data applications with Confluent and AWS - Lond...Ahmed791434
 
Building real-time serverless data applications with Confluent and AWS.pptx
Building real-time serverless data applications with Confluent and AWS.pptxBuilding real-time serverless data applications with Confluent and AWS.pptx
Building real-time serverless data applications with Confluent and AWS.pptxAhmed791434
 
20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECH20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECHMarcia Villalba
 
What's new in Serverless at AWS?
What's new in Serverless at AWS?What's new in Serverless at AWS?
What's new in Serverless at AWS?Daniel Zivkovic
 
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...⛷️ Ben Smith
 
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用Amazon Web Services
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluentconfluent
 
Confluent_AWS_ImmersionDay_Q42023.pdf
Confluent_AWS_ImmersionDay_Q42023.pdfConfluent_AWS_ImmersionDay_Q42023.pdf
Confluent_AWS_ImmersionDay_Q42023.pdfAhmed791434
 
Serverless-First Function: Serverless application security
Serverless-First Function: Serverless application securityServerless-First Function: Serverless application security
Serverless-First Function: Serverless application securityRobSutter2
 
What can you do with Serverless in 2020
What can you do with Serverless in 2020What can you do with Serverless in 2020
What can you do with Serverless in 2020Boaz Ziniman
 
AWS CZSK Webinář 2020.03: AWS Outposts
AWS CZSK Webinář 2020.03: AWS OutpostsAWS CZSK Webinář 2020.03: AWS Outposts
AWS CZSK Webinář 2020.03: AWS OutpostsVladimir Simek
 

Similar to AWS re:Invent serverless recap day: Controls for-managing-events-in-serverless-applications (20)

Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Getting started building your first serverless web application on AWS
Getting started building  your first serverless web application on AWSGetting started building  your first serverless web application on AWS
Getting started building your first serverless web application on AWS
 
Serverless AWS reInvent 2019 recap
Serverless AWS reInvent 2019 recapServerless AWS reInvent 2019 recap
Serverless AWS reInvent 2019 recap
 
Keynote Gregor Hohpe - Serverless Architectures
Keynote Gregor Hohpe - Serverless ArchitecturesKeynote Gregor Hohpe - Serverless Architectures
Keynote Gregor Hohpe - Serverless Architectures
 
AWSome Day Online 2020_Modul 3: Membangun di Cloud
AWSome Day Online 2020_Modul 3: Membangun di CloudAWSome Day Online 2020_Modul 3: Membangun di Cloud
AWSome Day Online 2020_Modul 3: Membangun di Cloud
 
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
Track 4 Session 3_ 利用 AWS Step Functions 建構穩健的業務處理流程
 
Leveraging serverless in fullstack development
Leveraging serverless in fullstack developmentLeveraging serverless in fullstack development
Leveraging serverless in fullstack development
 
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS Cloud
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS CloudAWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS Cloud
AWSome Day Online 2020_โมดูล 3: การวางระบบบน AWS Cloud
 
Building real-time serverless data applications with Confluent and AWS - Lond...
Building real-time serverless data applications with Confluent and AWS - Lond...Building real-time serverless data applications with Confluent and AWS - Lond...
Building real-time serverless data applications with Confluent and AWS - Lond...
 
Building real-time serverless data applications with Confluent and AWS.pptx
Building real-time serverless data applications with Confluent and AWS.pptxBuilding real-time serverless data applications with Confluent and AWS.pptx
Building real-time serverless data applications with Confluent and AWS.pptx
 
20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECH20200803 - Serverless with AWS @ HELTECH
20200803 - Serverless with AWS @ HELTECH
 
What's new in Serverless at AWS?
What's new in Serverless at AWS?What's new in Serverless at AWS?
What's new in Serverless at AWS?
 
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
AWS re:Invent serverless recap day: Whats new with AWS StepFunctions. - Expre...
 
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用
Track 4 Session 1_MAD01 如何活用事件驅動架構快速擴展應用
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
 
Confluent_AWS_ImmersionDay_Q42023.pdf
Confluent_AWS_ImmersionDay_Q42023.pdfConfluent_AWS_ImmersionDay_Q42023.pdf
Confluent_AWS_ImmersionDay_Q42023.pdf
 
Serverless-First Function: Serverless application security
Serverless-First Function: Serverless application securityServerless-First Function: Serverless application security
Serverless-First Function: Serverless application security
 
What can you do with Serverless in 2020
What can you do with Serverless in 2020What can you do with Serverless in 2020
What can you do with Serverless in 2020
 
AWS CZSK Webinář 2020.03: AWS Outposts
AWS CZSK Webinář 2020.03: AWS OutpostsAWS CZSK Webinář 2020.03: AWS Outposts
AWS CZSK Webinář 2020.03: AWS Outposts
 
Microservices & Data Design
Microservices & Data DesignMicroservices & Data Design
Microservices & Data Design
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
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 WorkerThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
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
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

AWS re:Invent serverless recap day: Controls for-managing-events-in-serverless-applications

  • 1. © 2020, Amazon Web Services, Inc. or its Affiliates. Controls for Managing Events in Serverless Applications Ben Smith Senior Developer Advocate, AWS Serverless @benjamin_l_s
  • 2. © 2020, Amazon Web Services, Inc. or its Affiliates. Agenda Asynchronous invocations controls Stream processing invocation controls
  • 3. © 2020, Amazon Web Services, Inc. or its Affiliates. Monoliths and microservices Monolith Does everything Microservices Does one thing
  • 4. © 2020, Amazon Web Services, Inc. or its Affiliates. The end goal And do it faster
  • 5. © 2020, Amazon Web Services, Inc. or its Affiliates. Architecture v1 This is fine for a simple command orientated design
  • 6. © 2020, Amazon Web Services, Inc. or its Affiliates. Architecture v2 But the Order service needs additional logic for each additional downstream service
  • 7. © 2020, Amazon Web Services, Inc. or its Affiliates. Long-term architecture The Order service soon becomes a blocker when integrating new services
  • 8. © 2020, Amazon Web Services, Inc. or its Affiliates. Events to the rescue
  • 9. © 2020, Amazon Web Services, Inc. or its Affiliates. [i-’vent]
  • 10. © 2020, Amazon Web Services, Inc. or its Affiliates. Events are observable, not directed
  • 11. © 2020, Amazon Web Services, Inc. or its Affiliates. Long-term architecture Hooking services together this way Prevents teams from moving fast
  • 12. © 2020, Amazon Web Services, Inc. or its Affiliates. Event routers for fan out Event router Router determines which downstream systems receive each event
  • 13. © 2020, Amazon Web Services, Inc. or its Affiliates. Amazon EventBridge schema registry
  • 14. © 2020, Amazon Web Services, Inc. or its Affiliates. A serverless event bus service for SaaS and AWS services • Fully managed, pay-as-you-go • Native integration with SaaS providers • 17 target services • Easily build event-driven architectures
  • 15. © 2020, Amazon Web Services, Inc. or its Affiliates. • Source of truth for sharing schema • Explicitly published and auto- discovered • Integrations forVS Code and JetBrains • Language bindings for Java, Python, andTypeScript Schema registry
  • 16. © 2020, Amazon Web Services, Inc. or its Affiliates. Serverless
  • 17. © 2020, Amazon Web Services, Inc. or its Affiliates. What is serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure
  • 18. © 2020, Amazon Web Services, Inc. or its Affiliates. Event-driven compute Functions as a service Serverless FaaS
  • 19. © 2020, Amazon Web Services, Inc. or its Affiliates. Serverless applications Event source / invocation Services Changes in data state Requests to endpoints Changes in Resource state Function Node.js Python Java C# Go Ruby Runtime API
  • 20. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda execution model Synchronous (push) Asynchronous (event) Stream (Poll-based) Amazon DynamoDB Amazon SNS /order Amazon S3 reqs Amazon Kinesis changes AWS Lambda service Amazon API Gateway Lambda function Lambda function function
  • 21. © 2020, Amazon Web Services, Inc. or its Affiliates. Asynchronous Invocations
  • 22. © 2020, Amazon Web Services, Inc. or its Affiliates. Async under the hood • Lambda polls one event at a time and invokes a function • Lambda only deletes a message/request after processing successfully Events Event Queue Lambda function
  • 23. © 2020, Amazon Web Services, Inc. or its Affiliates. What could possibly go wrong? • Function errors, retried twice • Throttling and system errors, retried for up to six hours • Duplicated processing
  • 24. © 2020, Amazon Web Services, Inc. or its Affiliates. When retries are not meaningful Use these new controls: • Event age (Default/Maximum: 6 hours, Minimum: 60s) • Retry attempts (Default/Maximum: 2, Minimum: 0)
  • 25. © 2020, Amazon Web Services, Inc. or its Affiliates. How to configure? In the AWS Management Console Using the AWS Serverless Application Model (SAM)
  • 26. © 2020, Amazon Web Services, Inc. or its Affiliates. Async under the hood • Lambda returns 2xx status code to confirm event received Events Event Queue Lambda function 202 response
  • 27. © 2020, Amazon Web Services, Inc. or its Affiliates. Do more with less code using Lambda Destinations Lambda SNS SQS EventBridge Lambda Success/Failure "version": "timestamp": "requestContext": { "requestId": "functionArn": "condition": "approximateInvokeCount”:}, "requestPayload": {}, "responseContext": { "statusCode": "executedVersion":}, "responsePayload": {} Execution Result being sent to downstream
  • 28. © 2020, Amazon Web Services, Inc. or its Affiliates. Before Lambda Destinations Response Total running time ms Idle running time Idle running time Synchronous Lambda chaining means paying for Idle wait times.
  • 29. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda Destinations On Success Response Total running time ms Using Lambda Destinations OnSuccess, you can chain functions asynchronously without paying for idle wait time.
  • 30. © 2020, Amazon Web Services, Inc. or its Affiliates. Lambda Destinations On Failure S3 Identify EventBridge SQS S3 S3 Transform Transform Process Error On Failure Handle function failures without coding extra logic using Lambda Destinations OnFailure.
  • 31. © 2020, Amazon Web Services, Inc. or its Affiliates. Use Destinations for: • Building simple workflow by chaining Lambda functions • Handling failures with additional context • Visibility and notification using EventBridge or SNS • Batching events to process with SQS or EventBridge
  • 32. © 2020, Amazon Web Services, Inc. or its Affiliates. Things to know… • Lambda execution role must have permission to access the destination service. • Execution result size shouldn’t exceed the payload size limit of downstream services • On-failure destination delivers more context than dead-letter queue.
  • 33. © 2020, Amazon Web Services, Inc. or its Affiliates. How to configure? In the AWS Management Console Using the AWS SAM
  • 34. © 2020, Amazon Web Services, Inc. or its Affiliates. Stream processing invocations (from Amazon Kinesis and Amazon DynamoDB)
  • 35. © 2020, Amazon Web Services, Inc. or its Affiliates. Processing Kinesis/ DynamoDB data streams Data Streams shard 1 shard 2 shard 3 shard 4 Data Producer Lambda as Data Consumer functionA (instance 1) functionA (instance 2) functionA (instance 3) functionA (instance 4) • By default Lambda processes one batch at a time per shard • Max concurrency = number of shards
  • 36. © 2020, Amazon Web Services, Inc. or its Affiliates. Sparse data off peak • By default, Lambda poller fetches data every second • Could result in batches with sparse data 1 second poller window
  • 37. © 2020, Amazon Web Services, Inc. or its Affiliates. Dealing with sparse data off peak with Batch Window • Batch Window allows to batch up to 300s before invocation. • New invocation criteria: 6MB payload, Maximum Batch Window, Maximum Batch Size Wait up to 300 seconds
  • 38. © 2020, Amazon Web Services, Inc. or its Affiliates. Dealing with data spikes with Parallelization Factor • Parallelization Factor (PF) allows you to have up to 10 batches per shard. Order is guaranteed at partition key level. • Faster stream processing without over-scaling Amazon Kinesis Shard 1213 Record Processor Consistent hashing 1 2 1 3 Batcher 1 Batcher 2 Batcher 3 --parallelization-factor 3
  • 39. © 2020, Amazon Web Services, Inc. or its Affiliates. Failures on stream processing • Malformed data leads to stuck shard and infinite (~10000) retries. • Records are always retried in batches, which made it hard to identify the bad record. • 1 malformed record can block the entire stream, the “poison pill”
  • 40. © 2020, Amazon Web Services, Inc. or its Affiliates. No more stuck shards • Skip processing old records using MaximumRecordAgeInSeconds (60s to 7 days). • Specify how many retries on a record with MaximumRetryAttempts (0 to 10,000). • Send metadata of failed records to SNS/SQS using on-failure destination.
  • 41. © 2020, Amazon Web Services, Inc. or its Affiliates. Trace down the bad record with Bisect On Function Error Batch size = 9, Bisect = true, MaxRetryAttempt = 1 on-failure destination configured 1st invoke 2nd invoke 3rd invoke 4th invoke Error, Request ID 1, Retry = 0 5th invoke 6th invoke 7th invoke Error, Request ID 2, Retry = 0 Success, Request ID 3, Retry = 0 Error, Request ID 4, Retry = 0 Success, Request ID 5, Retry = 0 Error, Request ID 6, Retry = 0 Error, Request ID 6, Retry = 1, sent to on-failure destination Record 1 -> 9 8th invoke Success, Request ID 7, Retry = 0
  • 42. © 2020, Amazon Web Services, Inc. or its Affiliates. Setting the new stream processing controls
  • 43. © 2020, Amazon Web Services, Inc. or its Affiliates. Summary Asynchronous Invocations Manage event schemas with Schema Registry Schema Discovery Manage retries with MaximumEventAgeInSeconds MaximumRetryAttempts Do more with less code Lambda Destinations OnSuccess OnFailure Stream Processing Invocations Handle sparse data with Batch Window Handle spikes with Parallelization Factor Eliminate ”poison pill” with BisectOnFunctionError Manage failures with MaximumRecordAgeInSeconds MaximumRetryAttempts OnFailureDestination Use these new controls to manage events in your serverless applications
  • 44. © 2020, Amazon Web Services, Inc. or its Affiliates. Thank you Ben Smith Senior Developer Advocate, AWS Serverless @benjamin_l_s