SlideShare a Scribd company logo
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Scalable serverless architectures using
event-driven design
Sam Dengler
Principal serverless solutions architect
Amazon Web Services
M A D 3 0 8
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Agenda
Serverless
Event-driven APIs
Messaging patterns
Serverless applications
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
What is serverless?
No infrastructure provisioning,
no management
Automatic scaling
Pay for value Highly available and secure
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
AWS
Lambda
AWS
Fargate
Amazon
API Gateway
Amazon Simple
Notification
Service
(Amazon SNS)
Amazon Simple
Queue Service
(Amazon SQS)
Compute
Data stores
Integration
Amazon Aurora
Serverless
Amazon Simple
Storage Service
(Amazon S3)
Amazon
DynamoDB
AWS
AppSync
AWS
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Lambda is event-driven by nature
Services (anything)
Changes in
data state
Requests to
endpoints
Changes in
resource state
Event source Function
Node.js
Python
Java
C#
Go
Ruby
BYOR (bring your own runtime)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Enterprise integration patterns
“A technology-independent vocabulary
and a visual notation to design and
document integration solutions.”
• Messages
• Filter
• Router
• Return address
• Claim check
https://www.enterpriseintegrationpatterns.com/
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
Lambda Fargate
API Gateway
Amazon
SNS
Amazon
SQS
Compute
Data stores
Integration
Amazon Aurora
Serverless
Amazon
S3
DynamoDB
AWS
AppSync
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Manage APIs with API Gateway
Mobile apps
Websites
Services
Internet Amazon
CloudFront
Amazon CloudWatch
monitoring
API
Gateway
cache
Any other
AWS service
All publicly
accessible
endpoints
Lambda
functions
Endpoints
in your VPC
Regional API endpoints
Lambda functions
Endpoints on Amazon
Elastic Cloud Compute
(Amazon EC2)
Your virtual private
cloud (VPC)
AWS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Challenges with synchronous serverless APIs
Client
API Gateway DynamoDBLambda
Timeouts
• API Gateway – 30 seconds
• Lambda – 15 minutes
Scale downstream resources
• Lambda – concurrent executions
• DynamoDB – read/write capacity units
Error handling
• Client responsibility
• Backoff/retry logic
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
API Gateway
Integration timeout: 30 seconds
Approaches
• Polling
• Webhooks
• WebSockets
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon S3 presigned URLs (claim check pattern)
• Uses permissions of the AWS Identity and Access
Management (IAM) user or role that creates the
URL
• To generate the URL, provide your security
credentials, a bucket name, an object key, HTTP
method (GET or PUT) and expiration date and
time
• Only valid until expiration time of the AWS
credentials or specified in the presign request
• Caution: Anyone with the URL can perform those
actions
Availability
Zone #1
Amazon EC2
instance
Generates
URL
Amazon
S3
Request access
Get or put
object
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
3. /status
Async: Polling
Flow
1. Client submits request and receives requestID
2. Backing service does work asynchronously, updating
job status
3. Client polls for status of request
4. Client fetches results when work is complete
Execution time
• < 15 mins – Step Functions (Lambda)
• >= 15 minutes – Step Functions (AWS Batch)
Throughput
• < 200 RPS (1K burst) – Direct SFn integration
• > 200 RPS – Lambda and Amazon SQS in front of SFn
Response payload
• > 10 MB – Amazon S3 presigned URL
Client
Amazon S3
1. /doWork
2
4. /getResults
API Gateway
API Gateway
API Gateway
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Async: Polling
Pros
• Minimal changes for client
• Can wrap existing backend
Cons
• Delayed response due to polling schedule
• Excess compute work for client and server
Client
Step FunctionsAPI Gateway
API Gateway
API Gateway Amazon S3
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SNS
Async: Webhooks Flow
0. (Optional) Trusted client configured with service
1. Client submits request; APIGW returns once request is
stored
2. Backing service does work asynchronously
3. Backing service calls back to client when work is complete
Client trust
• Trusted – Amazon SNS subscriptions with clientID filters
• Untrusted – Self sign-up endpoints or client provides
callback URL in request
Execution time
• < 15 minutes – Amazon SQS to Lambda
• >= 15 minutes – Step Functions or AWS Batch
Response payload
• <= 256 KB – Amazon SNS
• > 256 KB – Amazon SNS + Amazon S3 presigned URL
Client
1
3
2
Lambda
API Gateway
Amazon SQS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Async: Webhooks
Pros
• No polling; less resource-intensive for client and
server
• Amazon SNS handles delivery retries
Cons
• Client needs to host a web endpoint
• Need a documented retry policy
• For untrusted clients, you’re responsible for clients
demonstrating trust and retries
Amazon SNS
Amazon SQSClient
API Gateway
Lambda
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
WebSockets support in API Gateway
Real-time two-way
communications
Managed persistence
Event-based triggers
Mobile apps
Chat
Dashboards
Internet of
Things (IoT)
devices
API Gateway
WebSockets API
Stateful connection Stateless
connection
Lambda
functions
Public endpoints
on Amazon EC2
Amazon
Kinesis
Any other
AWS service
All publicly
accessible
endpoints
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Async: WebSockets
Flow
1. Client submits request and receives SFn execution ARN,
task token for OpenConn worker, and WebSocket
endpoint
2. Client opens connection to WebSocket endpoint with SFn
ARN and task token; Lambda completes OpenConn task
3. When DoWork is done, SFn parallel state completes, and
we send callback
4. Client receives update over WebSockets
Throughput
• < 200 RPS (1K burst) – Sync-SFn integration
• > 200 RPS – Lambda and Amazon SQS in front of SFn
Response payload
• > 128K (32K frame) – Amazon S3 presigned URL
Client
API Gateway
(WebSockets)
Step Functions1
2
3
4
LambdaAPI Gateway (REST)
onConnect
Step Functions workflow
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Async: WebSockets
Pros
• Direct client notification over open connection
• Richer eventing for client
• Web- and mobile-client friendly
Cons
• Requires familiarity with WebSocket protocol and related
libraries
• WebSockets not supported by all browsersClient Step Functions workflow
onConnect
http://bit.ly/aws-poll-to-push
API Gateway
(WebSockets)
Step FunctionsLambdaAPI Gateway (REST)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Lambda
Execution timeout: 15 minutes
Approaches
• Lambda Power Tuning1
• Step Functions
• Fargate/AWS Batch
https://github.com/alexcasalboni/aws-lambda-power-tuning
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
Decouple state from code using messaging
Orchestration
Sequencing
Parallel execution
State management
Step Functions
Eventing
Performance at scale
Fully managed
Enterprise-ready
Amazon SNS
Messaging
Durable and scalable
Fully managed
Comprehensive security
Amazon SQS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Lambda Fargate
API Gateway
Amazon
SNS
Amazon
SQS
Compute
Data stores
Integration
Amazon Aurora
Serverless
Amazon
S3
DynamoDB
AWS
AppSync
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Using Lambda with Amazon SQS
1. Scheduled time
occurs
2. Lambda invoked
CloudWatch Events
(time-based)
Queue
3. Pull messages from
queue
CloudWatch Events
(time-based)
4. Pull message from
queue
3. Lambda invoked
n times
2. Execute step function every
minute
1. Scheduled time
occurs
Queue Queue
Step Functions workflow
Lambda
Lambda
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SQS as an event source (SQSaaES)
• Lambda polls the queue, and when it detects new
messages, it invokes your Lambda function by passing
the messages as a parameter
• Full control over the queue-processing settings, such
as visibility timeouts, delay queues, redrive policy,
etc.; supports batch processing
• Lambda gradually increases the queue polling rate as
long as queue polling results in fetching new
messages
• Supports identity- and resource-based policy
3. Lambda removes
message from
queue
2. Lambda polls queue and
invokes function
1. Message inserted into to a
queue
Queue
Lambda
Amazon SQS
Lambda function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Lambda Fargate
API Gateway
Amazon
SNS
Amazon
SQS
Compute
Data stores
Integration
Amazon Aurora
Serverless
Amazon
S3
DynamoDB
AWS
AppSync
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Publish/subscribe
Subscriber A
Subscriber C
Subscriber B
• One logical publisher for a given domain event – fully enforces a consistent boundary
• Each subscriber can react to domain
events in their own bounded context
• Amazon SNS supports multiple
subscription channels – Lambda,
Amazon SQS, HTTP/S, email, SMS,
mobile push Topic
Publisher
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Service A
Service D
Service C
Subscriber B
Mapping events to topics
Grey
topic
Blue
topic
Blue
Subscribers
Grey
Each message type is mapped to logical destination
Blue
Blue
Grey
Grey
Lambda function
Publisher
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Amazon SNS message filters
• Publishers do not need to route message
• Subscribers do not need to filter for message of interest
• Lowers cost
Color
topicPublisher
Subscribers
BlueGrey
Attr=
Grey
Grey
Attr=
Blue
Blue
Filter policy
Attr=Grey
Filter policy
Attr=Blue
Service A
Service B
Service C
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Lambda Fargate
API Gateway
Amazon
SNS
Amazon
SQS
Compute
Data stores
Integration
Amazon Aurora
Serverless
Amazon
S3
DynamoDB
AWS
AppSync
Step Functions
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Coordination by function chaining
Lambda function Lambda function Lambda function
Lambda function Lambda function
Lambda function
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Step Functions
• Coordinate the components of distributed
applications and microservices using visual
workflows
• Keeps the orchestration out of the code!
• Ideal for long-running processes and implementing
failure management patterns and distributed
transaction processing
• Automatically triggers and tracks each step, and
retries when there are errors; support execution
logging
• Logs the state of each step, so when things do go
wrong, you can diagnose and debug problems
quickly
“Serverless” workflow management with zero
administration
"ProcessOrder": {
"Comment": ”t1”
"Type": "Task",
"Resource": "${NewOrderFunction.Arn}",
"TimeoutSeconds": 10,
"Catch": [{
"ErrorEquals": ["ErrProcessOrder"],
"ResultPath": "$.error",
"Next": "UpdateOrderStatus"
}],
"Next": "ProcessPayment"
},
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Step Functions
A
B C
A
?
CBA
BA
“I want to retry failed tasks”“I want to sequence tasks” “I want try/catch/finally”
“I want to select tasks based on data” “I want to run tasks in parallel”
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Richer workflows
Simplify building workloads such as order processing,
report generation, and data analysis
Write and maintain less code; add services in minutes
More service integrations
Step Functions
Amazon SNS Amazon SQS Amazon
SageMaker
AWS Glue AWS Batch Amazon ECS Fargate
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Simpler integration, less code
With serverless
polling
With new
service integration
Start
End
Lambda
functions
Start
End
No
Lambda
functions
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
Share reusable serverless applications using the
AWS Serverless Application Repository
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Nested apps using AWS Serverless Application Repository
Compose application architectures from
reusable building blocks
• Serverless architectures deployed as a set of nested
applications
• Foster best organizational practices and reduce
duplication of effort
• Share components, modules, and full applications
privately with teams or publicly with others to improve
agility
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Common patterns emerge
Storage and backup (nested serverless application)
Fork-pattern-
backup-queue
Fork-pattern-backup-
function
Fork-pattern-
backup-bucket
Search and analytics (nested serverless application)
Fork-pattern-
index-queue
Fork-pattern-
index-function
Fork-pattern-index-
table
Polls Saves
Polls Saves
Serverless application
Amazon
SNS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Messaging and integration patterns
Event store (nested app)
Polls Saves
Publisher Amazon SNS
Publishes
Subscriber B
Step Functions workflow
Amazon SQS WorkerClient
DLQ
Saves
Decoupled messaging Publish/subscribe
Service A (bounded context)
Publishes
Queue
DynamoDB
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Awareness of messaging-payload size limits
Lambda
Sync: 6 MB
Async: 256 KB
Amazon
SQS
256 KB
Amazon
SNS
256 KB
(SMS) 1,600 b
Step Functions
32 KB
API Gateway
HTTP: 10 MB
WebSockets: 128 KB (32-MB frames)
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Conclusion
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
Benefits of event-driven serverless architectures
• Asynchronous communication decouples components to accommodate long-running
processing and avoid timeouts
• Queues buffer messages to decouple producers and consumers to prevent downstream
resources from being overwhelmed
• Topics scale many-to-many communication using pub/sub messaging
• No infrastructure to provision, manage, secure, or scale
• Cost is driven by message volume and payload size – No messages == No cost
© 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.

More Related Content

What's hot

Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
Amazon Web Services
 
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Amazon Web Services
 
Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM
Amazon Web Services
 
AWS Control Tower
AWS Control TowerAWS Control Tower
AWS Control Tower
CloudHesive
 
Introduction to AWS Cost Management
Introduction to AWS Cost ManagementIntroduction to AWS Cost Management
Introduction to AWS Cost Management
Amazon Web Services
 
AWS Data Analytics on AWS
AWS Data Analytics on AWSAWS Data Analytics on AWS
AWS Data Analytics on AWS
sampath439572
 
Solution architecture
Solution architectureSolution architecture
Solution architecture
Rajat Agrawal
 
Getting Started with Amazon Inspector
Getting Started with Amazon InspectorGetting Started with Amazon Inspector
Getting Started with Amazon Inspector
Amazon Web Services
 
Introduction to AWS Services and Cloud Computing
Introduction to AWS Services and Cloud ComputingIntroduction to AWS Services and Cloud Computing
Introduction to AWS Services and Cloud Computing
Amazon Web Services
 
Cost Optimisation on AWS
Cost Optimisation on AWSCost Optimisation on AWS
Cost Optimisation on AWS
Amazon Web Services
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
Amazon Web Services
 
Cost Optimization on AWS
Cost Optimization on AWSCost Optimization on AWS
Cost Optimization on AWS
Amazon Web Services
 
Managing Security on AWS
Managing Security on AWSManaging Security on AWS
Managing Security on AWS
Amazon Web Services
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
Amazon Web Services
 
Azure automation
Azure automationAzure automation
Azure automation
Diego Henrique da Silva
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - Webinar
Amazon Web Services
 
Messaging in the AWS Cloud
Messaging in the AWS CloudMessaging in the AWS Cloud
Messaging in the AWS Cloud
Amazon Web Services
 
Containers - Amazon EKS
Containers - Amazon EKSContainers - Amazon EKS
Containers - Amazon EKS
Amazon Web Services
 
Securityhub
SecurityhubSecurityhub
Securityhub
Richard Harvey
 
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
Amazon Web Services Korea
 

What's hot (20)

Getting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and ServerlessGetting Started with AWS Lambda and Serverless
Getting Started with AWS Lambda and Serverless
 
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
Migration to AWS: The foundation for enterprise transformation - SVC210 - New...
 
Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM Protecting Your Data With AWS KMS and AWS CloudHSM
Protecting Your Data With AWS KMS and AWS CloudHSM
 
AWS Control Tower
AWS Control TowerAWS Control Tower
AWS Control Tower
 
Introduction to AWS Cost Management
Introduction to AWS Cost ManagementIntroduction to AWS Cost Management
Introduction to AWS Cost Management
 
AWS Data Analytics on AWS
AWS Data Analytics on AWSAWS Data Analytics on AWS
AWS Data Analytics on AWS
 
Solution architecture
Solution architectureSolution architecture
Solution architecture
 
Getting Started with Amazon Inspector
Getting Started with Amazon InspectorGetting Started with Amazon Inspector
Getting Started with Amazon Inspector
 
Introduction to AWS Services and Cloud Computing
Introduction to AWS Services and Cloud ComputingIntroduction to AWS Services and Cloud Computing
Introduction to AWS Services and Cloud Computing
 
Cost Optimisation on AWS
Cost Optimisation on AWSCost Optimisation on AWS
Cost Optimisation on AWS
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
 
Cost Optimization on AWS
Cost Optimization on AWSCost Optimization on AWS
Cost Optimization on AWS
 
Managing Security on AWS
Managing Security on AWSManaging Security on AWS
Managing Security on AWS
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
Azure automation
Azure automationAzure automation
Azure automation
 
An Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - WebinarAn Introduction to the AWS Well Architected Framework - Webinar
An Introduction to the AWS Well Architected Framework - Webinar
 
Messaging in the AWS Cloud
Messaging in the AWS CloudMessaging in the AWS Cloud
Messaging in the AWS Cloud
 
Containers - Amazon EKS
Containers - Amazon EKSContainers - Amazon EKS
Containers - Amazon EKS
 
Securityhub
SecurityhubSecurityhub
Securityhub
 
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
[AWS Builders] AWS와 함께하는 클라우드 컴퓨팅
 

Similar to Scalable serverless architectures using event-driven design - MAD308 - New York AWS Summit

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
Amazon Web Services
 
Serverless workshop with Amazon Web Services
Serverless workshop with Amazon Web ServicesServerless workshop with Amazon Web Services
Serverless workshop with Amazon Web Services
TheFamily
 
The family - presentation on AWS Serverless
The family - presentation on AWS ServerlessThe family - presentation on AWS Serverless
The family - presentation on AWS Serverless
Alexandre Pinhel
 
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
Amazon Web Services
 
Introduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless ApplicationsIntroduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless Applications
Amazon Web Services
 
Serverless Computing How to Innovate Faster
Serverless Computing How to Innovate FasterServerless Computing How to Innovate Faster
Serverless Computing How to Innovate Faster
Amazon Web Services
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
AWS Summits
 
Build and run applications without thinking about servers
Build and run applications without thinking about serversBuild and run applications without thinking about servers
Build and run applications without thinking about servers
Amazon Web Services
 
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS SummitBuild Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
Amazon Web Services
 
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...
Amazon Web Services
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
Amazon Web Services
 
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...
Amazon Web Services
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
AWS Summits
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Amazon Web Services
 
A Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureA Brief Look at Serverless Architecture
A Brief Look at Serverless Architecture
Amazon Web Services
 
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
Amazon Web Services
 
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS SummitBuilding Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
Amazon Web Services
 
Build a Serverless Web Application
Build a Serverless Web ApplicationBuild a Serverless Web Application
Build a Serverless Web Application
Amazon Web Services
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Amazon Web Services
 
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS SummitBuild Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
Amazon Web Services
 

Similar to Scalable serverless architectures using event-driven design - MAD308 - New York 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
 
Serverless workshop with Amazon Web Services
Serverless workshop with Amazon Web ServicesServerless workshop with Amazon Web Services
Serverless workshop with Amazon Web Services
 
The family - presentation on AWS Serverless
The family - presentation on AWS ServerlessThe family - presentation on AWS Serverless
The family - presentation on AWS Serverless
 
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
Intro to AWS Lambda and Serverless Applications: re:Invent 2018 Recap at the ...
 
Introduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless ApplicationsIntroduction to AWS Lambda and Serverless Applications
Introduction to AWS Lambda and Serverless Applications
 
Serverless Computing How to Innovate Faster
Serverless Computing How to Innovate FasterServerless Computing How to Innovate Faster
Serverless Computing How to Innovate Faster
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Build and run applications without thinking about servers
Build and run applications without thinking about serversBuild and run applications without thinking about servers
Build and run applications without thinking about servers
 
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS SummitBuild Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Atlanta AWS Summit
 
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...
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
 
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...
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019 Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
Let Your Business Logic go Serverless | AWS Summit Tel Aviv 2019
 
A Brief Look at Serverless Architecture
A Brief Look at Serverless ArchitectureA Brief Look at Serverless Architecture
A Brief Look at Serverless Architecture
 
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
 
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS SummitBuilding Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
Building Serverless Enterprise Applications - SRV315 - Anaheim AWS Summit
 
Build a Serverless Web Application
Build a Serverless Web ApplicationBuild a Serverless Web Application
Build a Serverless Web Application
 
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS SummitBuilding serverless enterprise applications - SRV315 - Toronto AWS Summit
Building serverless enterprise applications - SRV315 - Toronto AWS Summit
 
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS SummitBuild Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
Build Enterprise-Grade Serverless Apps - SRV315 - Chicago AWS Summit
 

More from Amazon Web Services

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...
Amazon Web Services
 
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...
Amazon Web Services
 
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
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
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
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
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...
Amazon Web Services
 
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...
Amazon Web Services
 
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
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
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
Amazon Web Services
 
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
Amazon Web Services
 
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
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
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
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
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 
Come costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSCome costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWS
Amazon Web Services
 
AWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei serverAWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei server
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
 
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
 
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
 
Come costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWSCome costruire un'architettura Serverless nel Cloud AWS
Come costruire un'architettura Serverless nel Cloud AWS
 
AWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei serverAWS Serverless per startup: come innovare senza preoccuparsi dei server
AWS Serverless per startup: come innovare senza preoccuparsi dei server
 

Scalable serverless architectures using event-driven design - MAD308 - New York AWS Summit

  • 1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Scalable serverless architectures using event-driven design Sam Dengler Principal serverless solutions architect Amazon Web Services M A D 3 0 8
  • 2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Agenda Serverless Event-driven APIs Messaging patterns Serverless applications
  • 3. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 4. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T What is serverless? No infrastructure provisioning, no management Automatic scaling Pay for value Highly available and secure
  • 5. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T AWS Lambda AWS Fargate Amazon API Gateway Amazon Simple Notification Service (Amazon SNS) Amazon Simple Queue Service (Amazon SQS) Compute Data stores Integration Amazon Aurora Serverless Amazon Simple Storage Service (Amazon S3) Amazon DynamoDB AWS AppSync AWS Step Functions
  • 6. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Lambda is event-driven by nature Services (anything) Changes in data state Requests to endpoints Changes in resource state Event source Function Node.js Python Java C# Go Ruby BYOR (bring your own runtime)
  • 7. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Enterprise integration patterns “A technology-independent vocabulary and a visual notation to design and document integration solutions.” • Messages • Filter • Router • Return address • Claim check https://www.enterpriseintegrationpatterns.com/
  • 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 Lambda Fargate API Gateway Amazon SNS Amazon SQS Compute Data stores Integration Amazon Aurora Serverless Amazon S3 DynamoDB AWS AppSync Step Functions
  • 10. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Manage APIs with API Gateway Mobile apps Websites Services Internet Amazon CloudFront Amazon CloudWatch monitoring API Gateway cache Any other AWS service All publicly accessible endpoints Lambda functions Endpoints in your VPC Regional API endpoints Lambda functions Endpoints on Amazon Elastic Cloud Compute (Amazon EC2) Your virtual private cloud (VPC) AWS
  • 11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Challenges with synchronous serverless APIs Client API Gateway DynamoDBLambda Timeouts • API Gateway – 30 seconds • Lambda – 15 minutes Scale downstream resources • Lambda – concurrent executions • DynamoDB – read/write capacity units Error handling • Client responsibility • Backoff/retry logic
  • 12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T API Gateway Integration timeout: 30 seconds Approaches • Polling • Webhooks • WebSockets
  • 13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon S3 presigned URLs (claim check pattern) • Uses permissions of the AWS Identity and Access Management (IAM) user or role that creates the URL • To generate the URL, provide your security credentials, a bucket name, an object key, HTTP method (GET or PUT) and expiration date and time • Only valid until expiration time of the AWS credentials or specified in the presign request • Caution: Anyone with the URL can perform those actions Availability Zone #1 Amazon EC2 instance Generates URL Amazon S3 Request access Get or put object
  • 14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T 3. /status Async: Polling Flow 1. Client submits request and receives requestID 2. Backing service does work asynchronously, updating job status 3. Client polls for status of request 4. Client fetches results when work is complete Execution time • < 15 mins – Step Functions (Lambda) • >= 15 minutes – Step Functions (AWS Batch) Throughput • < 200 RPS (1K burst) – Direct SFn integration • > 200 RPS – Lambda and Amazon SQS in front of SFn Response payload • > 10 MB – Amazon S3 presigned URL Client Amazon S3 1. /doWork 2 4. /getResults API Gateway API Gateway API Gateway Step Functions
  • 15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Async: Polling Pros • Minimal changes for client • Can wrap existing backend Cons • Delayed response due to polling schedule • Excess compute work for client and server Client Step FunctionsAPI Gateway API Gateway API Gateway Amazon S3
  • 16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SNS Async: Webhooks Flow 0. (Optional) Trusted client configured with service 1. Client submits request; APIGW returns once request is stored 2. Backing service does work asynchronously 3. Backing service calls back to client when work is complete Client trust • Trusted – Amazon SNS subscriptions with clientID filters • Untrusted – Self sign-up endpoints or client provides callback URL in request Execution time • < 15 minutes – Amazon SQS to Lambda • >= 15 minutes – Step Functions or AWS Batch Response payload • <= 256 KB – Amazon SNS • > 256 KB – Amazon SNS + Amazon S3 presigned URL Client 1 3 2 Lambda API Gateway Amazon SQS
  • 17. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Async: Webhooks Pros • No polling; less resource-intensive for client and server • Amazon SNS handles delivery retries Cons • Client needs to host a web endpoint • Need a documented retry policy • For untrusted clients, you’re responsible for clients demonstrating trust and retries Amazon SNS Amazon SQSClient API Gateway Lambda
  • 18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T WebSockets support in API Gateway Real-time two-way communications Managed persistence Event-based triggers Mobile apps Chat Dashboards Internet of Things (IoT) devices API Gateway WebSockets API Stateful connection Stateless connection Lambda functions Public endpoints on Amazon EC2 Amazon Kinesis Any other AWS service All publicly accessible endpoints
  • 19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Async: WebSockets Flow 1. Client submits request and receives SFn execution ARN, task token for OpenConn worker, and WebSocket endpoint 2. Client opens connection to WebSocket endpoint with SFn ARN and task token; Lambda completes OpenConn task 3. When DoWork is done, SFn parallel state completes, and we send callback 4. Client receives update over WebSockets Throughput • < 200 RPS (1K burst) – Sync-SFn integration • > 200 RPS – Lambda and Amazon SQS in front of SFn Response payload • > 128K (32K frame) – Amazon S3 presigned URL Client API Gateway (WebSockets) Step Functions1 2 3 4 LambdaAPI Gateway (REST) onConnect Step Functions workflow
  • 20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Async: WebSockets Pros • Direct client notification over open connection • Richer eventing for client • Web- and mobile-client friendly Cons • Requires familiarity with WebSocket protocol and related libraries • WebSockets not supported by all browsersClient Step Functions workflow onConnect http://bit.ly/aws-poll-to-push API Gateway (WebSockets) Step FunctionsLambdaAPI Gateway (REST)
  • 21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Lambda Execution timeout: 15 minutes Approaches • Lambda Power Tuning1 • Step Functions • Fargate/AWS Batch https://github.com/alexcasalboni/aws-lambda-power-tuning
  • 22. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Decouple state from code using messaging Orchestration Sequencing Parallel execution State management Step Functions Eventing Performance at scale Fully managed Enterprise-ready Amazon SNS Messaging Durable and scalable Fully managed Comprehensive security Amazon SQS
  • 24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Lambda Fargate API Gateway Amazon SNS Amazon SQS Compute Data stores Integration Amazon Aurora Serverless Amazon S3 DynamoDB AWS AppSync Step Functions
  • 25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Using Lambda with Amazon SQS 1. Scheduled time occurs 2. Lambda invoked CloudWatch Events (time-based) Queue 3. Pull messages from queue CloudWatch Events (time-based) 4. Pull message from queue 3. Lambda invoked n times 2. Execute step function every minute 1. Scheduled time occurs Queue Queue Step Functions workflow Lambda Lambda
  • 26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SQS as an event source (SQSaaES) • Lambda polls the queue, and when it detects new messages, it invokes your Lambda function by passing the messages as a parameter • Full control over the queue-processing settings, such as visibility timeouts, delay queues, redrive policy, etc.; supports batch processing • Lambda gradually increases the queue polling rate as long as queue polling results in fetching new messages • Supports identity- and resource-based policy 3. Lambda removes message from queue 2. Lambda polls queue and invokes function 1. Message inserted into to a queue Queue Lambda Amazon SQS Lambda function
  • 27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Lambda Fargate API Gateway Amazon SNS Amazon SQS Compute Data stores Integration Amazon Aurora Serverless Amazon S3 DynamoDB AWS AppSync Step Functions
  • 28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Publish/subscribe Subscriber A Subscriber C Subscriber B • One logical publisher for a given domain event – fully enforces a consistent boundary • Each subscriber can react to domain events in their own bounded context • Amazon SNS supports multiple subscription channels – Lambda, Amazon SQS, HTTP/S, email, SMS, mobile push Topic Publisher
  • 29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Service A Service D Service C Subscriber B Mapping events to topics Grey topic Blue topic Blue Subscribers Grey Each message type is mapped to logical destination Blue Blue Grey Grey Lambda function Publisher
  • 30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Amazon SNS message filters • Publishers do not need to route message • Subscribers do not need to filter for message of interest • Lowers cost Color topicPublisher Subscribers BlueGrey Attr= Grey Grey Attr= Blue Blue Filter policy Attr=Grey Filter policy Attr=Blue Service A Service B Service C
  • 31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Lambda Fargate API Gateway Amazon SNS Amazon SQS Compute Data stores Integration Amazon Aurora Serverless Amazon S3 DynamoDB AWS AppSync Step Functions
  • 32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Coordination by function chaining Lambda function Lambda function Lambda function Lambda function Lambda function Lambda function
  • 33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Step Functions • Coordinate the components of distributed applications and microservices using visual workflows • Keeps the orchestration out of the code! • Ideal for long-running processes and implementing failure management patterns and distributed transaction processing • Automatically triggers and tracks each step, and retries when there are errors; support execution logging • Logs the state of each step, so when things do go wrong, you can diagnose and debug problems quickly “Serverless” workflow management with zero administration "ProcessOrder": { "Comment": ”t1” "Type": "Task", "Resource": "${NewOrderFunction.Arn}", "TimeoutSeconds": 10, "Catch": [{ "ErrorEquals": ["ErrProcessOrder"], "ResultPath": "$.error", "Next": "UpdateOrderStatus" }], "Next": "ProcessPayment" },
  • 34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Step Functions A B C A ? CBA BA “I want to retry failed tasks”“I want to sequence tasks” “I want try/catch/finally” “I want to select tasks based on data” “I want to run tasks in parallel”
  • 35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Richer workflows Simplify building workloads such as order processing, report generation, and data analysis Write and maintain less code; add services in minutes More service integrations Step Functions Amazon SNS Amazon SQS Amazon SageMaker AWS Glue AWS Batch Amazon ECS Fargate
  • 36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Simpler integration, less code With serverless polling With new service integration Start End Lambda functions Start End No Lambda functions
  • 37. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
  • 38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Share reusable serverless applications using the AWS Serverless Application Repository
  • 39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Nested apps using AWS Serverless Application Repository Compose application architectures from reusable building blocks • Serverless architectures deployed as a set of nested applications • Foster best organizational practices and reduce duplication of effort • Share components, modules, and full applications privately with teams or publicly with others to improve agility
  • 40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Common patterns emerge Storage and backup (nested serverless application) Fork-pattern- backup-queue Fork-pattern-backup- function Fork-pattern- backup-bucket Search and analytics (nested serverless application) Fork-pattern- index-queue Fork-pattern- index-function Fork-pattern-index- table Polls Saves Polls Saves Serverless application Amazon SNS
  • 41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Messaging and integration patterns Event store (nested app) Polls Saves Publisher Amazon SNS Publishes Subscriber B Step Functions workflow Amazon SQS WorkerClient DLQ Saves Decoupled messaging Publish/subscribe Service A (bounded context) Publishes Queue DynamoDB
  • 42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Awareness of messaging-payload size limits Lambda Sync: 6 MB Async: 256 KB Amazon SQS 256 KB Amazon SNS 256 KB (SMS) 1,600 b Step Functions 32 KB API Gateway HTTP: 10 MB WebSockets: 128 KB (32-MB frames)
  • 43. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Conclusion
  • 44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T Benefits of event-driven serverless architectures • Asynchronous communication decouples components to accommodate long-running processing and avoid timeouts • Queues buffer messages to decouple producers and consumers to prevent downstream resources from being overwhelmed • Topics scale many-to-many communication using pub/sub messaging • No infrastructure to provision, manage, secure, or scale • Cost is driven by message volume and payload size – No messages == No cost
  • 45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.S U M M I T
  • 46. Thank you! S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.