SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Best practices for queue processing in
serverless applications
Luay Kawasme
Sr. Manager, Software Development
Amazon SQS
Amazon Web Services
M A D 3 1 3
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Build microservices with serverless technologies
No infrastructure to
provision or manage
Scales automatically
by unit of consumption
Pay for value Built-in security
highly available compute
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
What is Amazon SQS?
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
What is Amazon Lambda?
Synchronous push model
Pull model
Asynchronous push model
Alexa Skill
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
AWS Lambda invocation integrations
Amazon S3
Amazon DynamoDB
Amazon Kinesis Data Streams
Amazon SNS
Amazon Simple Email Service
Amazon SQS
Amazon Cognito
AWS CloudFormation
Amazon CloudWatch Logs
Amazon CloudWatch Events
AWS CodeCommit
AWS Config
Amazon Alexa
Amazon Lex
Amazon API Gateway
AWS IoT Button
and more…
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Pipes and filters
A single event triggers a sequence of processing steps. Typically, an event traverses
a pipeline and goes through several transformations
(e.g., filtering, enrichment).
Message
Queue
Lambda function
Queue
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Serverless message processing
1. Message inserted into to a queue
2. Lambda polls queue and
invokes function
Queue Lambda Function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Serverless message processing
1. Message inserted into to a queue
2. Lambda polls queue and
invokes function
3. Lambda removes message from
queue
Queue Lambda Function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SQS to Lambda
1. Message inserted into to a queue
2. Lambda polls queue and invokes
function
3. Lambda removes message
from queue
Serverless processing
Lambda polls queue for messages
Processed in batches
Message processing
Messages are stored durably
Queue accepts messages at any rate
No need to provision capacity
Visibility timeout for failure processing
Queue Lambda function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
AWS Lambda async push vs. Amazon SQS
AWS Lambda async invoke
• Direct integration
• Automatic scaling
• No batching
• Simple DLQ policy
• No backlog visibility
• No extra queue features
• No extra cost
Amazon SQS + AWS Lambda
• Two resources
• Automatic scaling
• Supports batching
• Advanced DLQ policy
• Amazon CloudWatch metrics
• All SQS features
• Cost of requests to SQS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Advanced Amazon SQS features
Advanced DLQ policy
Batching
Delayed messages
Server-side encryption with customer managed key (CMK)
Retention period
Message attributes
CloudWatch metrics
Purge operation
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Consuming from Amazon SQS
C
C
C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Inside Amazon SQS: Visibility timeouts
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SQS to Lambda: Details
Lambda
function
Message
batch
Queue
Message
batch
Message
batch
Message
batch
Message
batch
Lambda
function
Lambda
function
Lambda
function
Lambda
function
Lambda
function
Message
batch
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Highly scalable processing
1. Message inserted into to a queue
2. Lambda polls queue and
invokes function
3. Lambda removes message from
queue
Queue Lambda Function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Downstream dependency with a limit
1. Message inserted into to a queue
2. Lambda polls queue and
invokes function
3. Lambda removes message from
queue
Queue Lambda Function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Limiting concurrency
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Demo
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SNS or Amazon SQS as an event source?
Comparison SNS as an event source for Lambda SQS as an event source for Lambda
Scale/
concurrency
Automatic scaling, per function concurrency Same
Durability Durable storage across multiple AZs Same
Consumption
model
Messages pushed to Lambda; Amazon SNS can
“fanout” the same message
Lambda polls for messages and invokes function; each
message is consumed and deleted by Lambda
Resilience Once delivered, message is deleted, even if
Lambda function does not complete processing
Lambda function is responsible for deleting message
after processing; ability to monitor and control queue
Persistence/
retries
Delivery retry logic that extends up through
potentially 13 hours
Message retention for up to 14 days
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SQS to Lambda: Tips
• For low-concurrency, high-duration functions, set Visibility Timeout to 5x
function duration. This will avoid receiveCount retries and DLQ.
• Check that visibilityTimeout is always greater than function duration to avoid
duplicate invokes.
• Even a fraction of errors will induce backpressure and interfere with ramping up
to full concurrency.
• The number of invocations does not equal throughput. Maximum batching is
not guaranteed.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Thank you!
S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Luay Kawasme
@luay_ca
https://www.linkedin.com/in/luayk/

Weitere ähnliche Inhalte

Was ist angesagt?

금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
Amazon Web Services Korea
 

Was ist angesagt? (20)

JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
JFokus: Cubes, Hexagons, Triangles, and More: Understanding MicroservicesJFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
JFokus: Cubes, Hexagons, Triangles, and More: Understanding Microservices
 
Landing Zones - Creating a Foundation for Your AWS Migrations
Landing Zones - Creating a Foundation for Your AWS MigrationsLanding Zones - Creating a Foundation for Your AWS Migrations
Landing Zones - Creating a Foundation for Your AWS Migrations
 
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
AWS Landing Zone Deep Dive (ENT350-R2) - AWS re:Invent 2018
 
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
Enterprise Governance: Build Your AWS Landing Zone (ENT351-R1) - AWS re:Inven...
 
Amazon Cognito Deep Dive
Amazon Cognito Deep DiveAmazon Cognito Deep Dive
Amazon Cognito Deep Dive
 
Security Architectures on AWS
Security Architectures on AWSSecurity Architectures on AWS
Security Architectures on AWS
 
Living the AWS Well Architected Framework
Living the AWS Well Architected FrameworkLiving the AWS Well Architected Framework
Living the AWS Well Architected Framework
 
AWS Security Hub
AWS Security HubAWS Security Hub
AWS Security Hub
 
Introduction to AWS Cost Management
Introduction to AWS Cost ManagementIntroduction to AWS Cost Management
Introduction to AWS Cost Management
 
AWS Web Application Firewall and AWS Shield - Webinar
AWS Web Application Firewall and AWS Shield - Webinar AWS Web Application Firewall and AWS Shield - Webinar
AWS Web Application Firewall and AWS Shield - Webinar
 
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
 
마이크로서비스 개요
마이크로서비스 개요마이크로서비스 개요
마이크로서비스 개요
 
Amazon EC2 & VPC HOL
Amazon EC2 & VPC HOLAmazon EC2 & VPC HOL
Amazon EC2 & VPC HOL
 
Threat detection on AWS: An introduction to Amazon GuardDuty - FND216 - AWS r...
Threat detection on AWS: An introduction to Amazon GuardDuty - FND216 - AWS r...Threat detection on AWS: An introduction to Amazon GuardDuty - FND216 - AWS r...
Threat detection on AWS: An introduction to Amazon GuardDuty - FND216 - AWS r...
 
An Overview of the AWS Cloud Adoption Framework - May 2017 AWS Online Tech Talks
An Overview of the AWS Cloud Adoption Framework - May 2017 AWS Online Tech TalksAn Overview of the AWS Cloud Adoption Framework - May 2017 AWS Online Tech Talks
An Overview of the AWS Cloud Adoption Framework - May 2017 AWS Online Tech Talks
 
Aws landing zone
Aws landing zoneAws landing zone
Aws landing zone
 
Amazon Kinesis
Amazon KinesisAmazon Kinesis
Amazon Kinesis
 
From Monolithic to Microservices (AWS & Digital Goodie)
From Monolithic to Microservices (AWS & Digital Goodie)From Monolithic to Microservices (AWS & Digital Goodie)
From Monolithic to Microservices (AWS & Digital Goodie)
 
금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
금융권 최신 AWS 도입 사례 총정리 – 신한 제주 은행, KB손해보험 사례를 중심으로 - 지성국 사업 개발 담당 이사, AWS / 정을용...
 
AWS Well-Architected Framework
AWS Well-Architected FrameworkAWS Well-Architected Framework
AWS Well-Architected Framework
 

Ähnlich wie Best practices for queue processing in serverless applications - MAD313 - Chicago AWS Summit

Ähnlich wie Best practices for queue processing in serverless applications - MAD313 - Chicago AWS Summit (20)

Thirty serverless architectures in 30 minutes - MAD202 - Chicago AWS Summit
Thirty serverless architectures in 30 minutes - MAD202 - Chicago AWS SummitThirty serverless architectures in 30 minutes - MAD202 - Chicago AWS Summit
Thirty serverless architectures in 30 minutes - MAD202 - Chicago AWS Summit
 
Scalable serverless architectures using event-driven design - MAD310 - Chicag...
Scalable serverless architectures using event-driven design - MAD310 - Chicag...Scalable serverless architectures using event-driven design - MAD310 - Chicag...
Scalable serverless architectures using event-driven design - MAD310 - Chicag...
 
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
 
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
Building a fully serverless application on AWS | AWS Summit Tel Aviv 2019
 
Best Practices for Queue Processing in Serverless Applications (SRV320) - AWS...
Best Practices for Queue Processing in Serverless Applications (SRV320) - AWS...Best Practices for Queue Processing in Serverless Applications (SRV320) - AWS...
Best Practices for Queue Processing in Serverless Applications (SRV320) - AWS...
 
Fulfilling_a_Billion_Requests_from_a_Global_SaaS_Company_Insights_into_AfterS...
Fulfilling_a_Billion_Requests_from_a_Global_SaaS_Company_Insights_into_AfterS...Fulfilling_a_Billion_Requests_from_a_Global_SaaS_Company_Insights_into_AfterS...
Fulfilling_a_Billion_Requests_from_a_Global_SaaS_Company_Insights_into_AfterS...
 
How to speed up and scale your innovation efforts - MAD203 - Chicago AWS Summit
How to speed up and scale your innovation efforts - MAD203 - Chicago AWS SummitHow to speed up and scale your innovation efforts - MAD203 - Chicago AWS Summit
How to speed up and scale your innovation efforts - MAD203 - Chicago AWS Summit
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
AWS Summit Singapore 2019 | Operating Microservices at Hyperscale
AWS Summit Singapore 2019 | Operating Microservices at HyperscaleAWS Summit Singapore 2019 | Operating Microservices at Hyperscale
AWS Summit Singapore 2019 | Operating Microservices at Hyperscale
 
Build data-drive, high performance, internet scale applications with AWS Data...
Build data-drive, high performance, internet scale applications with AWS Data...Build data-drive, high performance, internet scale applications with AWS Data...
Build data-drive, high performance, internet scale applications with AWS Data...
 
How Qantas is Scaling Cloud Operations with AWS Systems Manager - AWS Summit ...
How Qantas is Scaling Cloud Operations with AWS Systems Manager - AWS Summit ...How Qantas is Scaling Cloud Operations with AWS Systems Manager - AWS Summit ...
How Qantas is Scaling Cloud Operations with AWS Systems Manager - AWS Summit ...
 
AWS Summit Singapore 2019 | Next Generation Audit & Compliance - Learn how RH...
AWS Summit Singapore 2019 | Next Generation Audit & Compliance - Learn how RH...AWS Summit Singapore 2019 | Next Generation Audit & Compliance - Learn how RH...
AWS Summit Singapore 2019 | Next Generation Audit & Compliance - Learn how RH...
 
Serverless Observability Tech Talk
Serverless Observability Tech TalkServerless Observability Tech Talk
Serverless Observability Tech Talk
 
Websites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit BerlinWebsites go Serverless - AWS Summit Berlin
Websites go Serverless - AWS Summit Berlin
 
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
Favorire l'innovazione passando da applicazioni monolitiche ad architetture m...
 
How Nubank is building a customer-obsessed bank - FSV201 - New York AWS Summit
How Nubank is building a customer-obsessed bank - FSV201 - New York AWS SummitHow Nubank is building a customer-obsessed bank - FSV201 - New York AWS Summit
How Nubank is building a customer-obsessed bank - FSV201 - New York AWS Summit
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Building Event-Driven Applications with Serverless and AWS - AWS Summit New York
Building Event-Driven Applications with Serverless and AWS - AWS Summit New YorkBuilding Event-Driven Applications with Serverless and AWS - AWS Summit New York
Building Event-Driven Applications with Serverless and AWS - AWS Summit New York
 
A culture of rapid innovation with DevOps, microservices, & serverless - MAD2...
A culture of rapid innovation with DevOps, microservices, & serverless - MAD2...A culture of rapid innovation with DevOps, microservices, & serverless - MAD2...
A culture of rapid innovation with DevOps, microservices, & serverless - MAD2...
 
Serverless workshop with Amazon Web Services
Serverless workshop with Amazon Web ServicesServerless workshop with Amazon Web Services
Serverless workshop with Amazon Web Services
 

Mehr von 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
 

Mehr von 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
 

Best practices for queue processing in serverless applications - MAD313 - Chicago AWS Summit

  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Best practices for queue processing in serverless applications Luay Kawasme Sr. Manager, Software Development Amazon SQS Amazon Web Services M A D 3 1 3
  • 2. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 3. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Build microservices with serverless technologies No infrastructure to provision or manage Scales automatically by unit of consumption Pay for value Built-in security highly available compute
  • 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T What is Amazon SQS?
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T What is Amazon Lambda? Synchronous push model Pull model Asynchronous push model Alexa Skill
  • 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T AWS Lambda invocation integrations Amazon S3 Amazon DynamoDB Amazon Kinesis Data Streams Amazon SNS Amazon Simple Email Service Amazon SQS Amazon Cognito AWS CloudFormation Amazon CloudWatch Logs Amazon CloudWatch Events AWS CodeCommit AWS Config Amazon Alexa Amazon Lex Amazon API Gateway AWS IoT Button and more…
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Pipes and filters A single event triggers a sequence of processing steps. Typically, an event traverses a pipeline and goes through several transformations (e.g., filtering, enrichment). Message Queue Lambda function Queue
  • 8. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 9. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Serverless message processing 1. Message inserted into to a queue 2. Lambda polls queue and invokes function Queue Lambda Function
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Serverless message processing 1. Message inserted into to a queue 2. Lambda polls queue and invokes function 3. Lambda removes message from queue Queue Lambda Function
  • 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SQS to Lambda 1. Message inserted into to a queue 2. Lambda polls queue and invokes function 3. Lambda removes message from queue Serverless processing Lambda polls queue for messages Processed in batches Message processing Messages are stored durably Queue accepts messages at any rate No need to provision capacity Visibility timeout for failure processing Queue Lambda function
  • 12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T AWS Lambda async push vs. Amazon SQS AWS Lambda async invoke • Direct integration • Automatic scaling • No batching • Simple DLQ policy • No backlog visibility • No extra queue features • No extra cost Amazon SQS + AWS Lambda • Two resources • Automatic scaling • Supports batching • Advanced DLQ policy • Amazon CloudWatch metrics • All SQS features • Cost of requests to SQS
  • 13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Advanced Amazon SQS features Advanced DLQ policy Batching Delayed messages Server-side encryption with customer managed key (CMK) Retention period Message attributes CloudWatch metrics Purge operation
  • 14. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Consuming from Amazon SQS C C C
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Inside Amazon SQS: Visibility timeouts
  • 27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SQS to Lambda: Details Lambda function Message batch Queue Message batch Message batch Message batch Message batch Lambda function Lambda function Lambda function Lambda function Lambda function Message batch
  • 28. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo
  • 30. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Highly scalable processing 1. Message inserted into to a queue 2. Lambda polls queue and invokes function 3. Lambda removes message from queue Queue Lambda Function
  • 32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Downstream dependency with a limit 1. Message inserted into to a queue 2. Lambda polls queue and invokes function 3. Lambda removes message from queue Queue Lambda Function
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Limiting concurrency
  • 34. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Demo
  • 36. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 37. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SNS or Amazon SQS as an event source? Comparison SNS as an event source for Lambda SQS as an event source for Lambda Scale/ concurrency Automatic scaling, per function concurrency Same Durability Durable storage across multiple AZs Same Consumption model Messages pushed to Lambda; Amazon SNS can “fanout” the same message Lambda polls for messages and invokes function; each message is consumed and deleted by Lambda Resilience Once delivered, message is deleted, even if Lambda function does not complete processing Lambda function is responsible for deleting message after processing; ability to monitor and control queue Persistence/ retries Delivery retry logic that extends up through potentially 13 hours Message retention for up to 14 days
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SQS to Lambda: Tips • For low-concurrency, high-duration functions, set Visibility Timeout to 5x function duration. This will avoid receiveCount retries and DLQ. • Check that visibilityTimeout is always greater than function duration to avoid duplicate invokes. • Even a fraction of errors will induce backpressure and interfere with ramping up to full concurrency. • The number of invocations does not equal throughput. Maximum batching is not guaranteed.
  • 39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Thank you! S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Luay Kawasme @luay_ca https://www.linkedin.com/in/luayk/