SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
Serverless architectural patterns
Abby Fuller, AWS
@abbyfuller
What does serverless mean?
No servers to provision or
manage
Scale with your usage
Built in availability and fault-
tolerance
Never pay for idle/unused
capacity
Serverless runs on functions
• Functions are the unit of deployment and scale
• This scales per request!
• Skip the boring parts, skip the hard parts
Serverless applications
FUNCTION SERVICES (ANYTHING)
Changes in
data state
Requests to
endpoints
Changes in
resource state
Node
Python
Java
C#
EVENT SOURCE
Example event sources
Data stores Endpoints
Configuration repositories Event/message sources
Amazon S3 Amazon
DynamoDB
Amazon
Kinesis
Amazon
Cognito
Amazon IoT AWS Step
Functions
Amazon
Alexa
AWS
CloudTrail
AWS
CodeCommit
Amazon
CloudWatch
Amazon SES Amazon SNS Cron events
Amazon
API Gateway
AWS
Cloudformation
…and more!
A few Lambda specific best practices
• Lambda is stateless  architect accordingly!
• Assume no affinity with underlying compute infrastructure
• Local filesystem and child processes may not extend beyond the lifetime of
the Lambda request
Lambda considerations and best practices
• Can your Lambda functions survive the cold?
• Instantiate AWS clients and database
clients outside the scope of the handler to
take advantage of connection re-use.
• Schedule with CloudWatch Events for
warmth
• ENIs for VPC support are attached during
cold start
import sys
import logging
import rds_config
import pymysql
rds_host = "rds-instance"
db_name = rds_config.db_name
try:
conn = pymysql.connect(
except:
logger.error("ERROR:
def handler(event, context):
with conn.cursor() as cur:
Executes during
cold start
Executes with each
invocation
Lambda considerations and best practices
• How about a file system?
• Don’t forget about /tmp (512 MB
of scratch space)
exports.ffmpeg = function(event,context) {
new ffmpeg('./thumb.MP4', function (err,
video)
{
if (!err) { video.fnExtractFrameToJPG('/tmp’)
function (error, files) { … }
…
if (!error)
console.log(files);
context.done();
...
Lambda considerations and best practices
• Custom CloudWatch metrics
• 40 KB per POST
• Default Acct Limit of 150 TPS
• Consider aggregating with Kinesis
def put_cstate ( iid, state ):
response = cwclient.put_metric_data(
Namespace='AWSx/DirectConnect',
MetricData=[
{
'MetricName':'ConnectionState',
'Dimensions': [
{
'Name': 'ConnectionId',
'Value': iid
},
],
'Value': state,
'Unit': 'None’
A couple kinds of design patterns
Pattern one: 3-Tier Web Application
3-Tier web application
Browser
Amazon
CloudFront
Amazon S3
Amazon API
Gateway
Dynamic content in
AWS Lambda
Data store in Amazon
DynamoDB
Amazon API
Gateway AWS
Lambda
Amazon
DynamoDB
Amazon
S3
Amazon
CloudFront
• Bucket Policies
• ACLs
• OAI
• Geo-Restriction
• Signed Cookies
• Signed URLs
• DDOS
IAM
AuthZ
IAM
Serverless web app security
• Throttling
• Caching
• Usage Plans
Browser
Amazon API
Gateway AWS
Lambda
Amazon
DynamoDB
Amazon
S3
Amazon
CloudFront
• Bucket Policies
• ACLs
• OAI
• Geo-Restriction
• Signed Cookies
• Signed URLs
• DDOS
IAMAuthZ IAM
Serverless web app security
• Throttling
• Caching
• Usage Plans
Browser
Amazon
CloudFront
• HTTPS
• Disable Host Header
Forwarding
AWS WAF
Amazon API
Gateway
AWS
Lambda
Amazon
DynamoDB
Amazon
S3
Amazon
CloudFront
• Access Logs in S3 Bucket
• Access Logs in S3 Bucket
• CloudWatch Metrics-
https://aws.amazon.com/clo
udfront/reporting/
Serverless web app monitoring
AWS WAF
• WebACL Testing
• Total Requests
• Allowed/Blocked
Requests by ACL
logslogs
• Invocations
• Invocation Errors
• Duration
• Throttled Invocations
• Latency
• Throughput
• Throttled Reqs
• Returned Bytes
• Documentation
• Latency
• Count
• Cache Hit/Miss
• 4XX/5XX Errors
Streams
AWS
CloudTrail
Browser
Custom CloudWatch
Metrics & Alarms
Serverless web app lifecycle management
• AWS SAM (Serverless Application Model) - blog
AWS
Lambda
Amazon API
Gateway
AWS CloudFormationAmazon
S3
Amazon
DynamoDB
Package &
Deploy
Code/Packages/Swagger
Serverless
Template
Serverless
Template
w/ CodeUri
package deploy
CI/CD Tools
A couple words on Amazon API Gateway
• Use mock integrations
• Signed URL from API Gateway for large or binary file uploads to S3
• Use request/response mapping templates for legacy apps and HTTP
response codes
• Asynchronous calls for Lambda > 30s
Root/
/{proxy+} ANY Node.js Express
app
• Simple yet very powerful:
• Automatically scale to meet demand
• Only pay for the requests you receive
Greedy variable, ANY method, proxy integration
Pattern two: Batch processing
Characteristics of batch processing
• Large data sets
• Periodic or scheduled tasks
• Extract Transform Load (ETL) jobs
• Usually non-interactive and long running
• Many problems fit MapReduce programming model
AWS Lambda:
Splitter
Amazon S3
Object
Amazon DynamoDB:
Mapper Results
AWS Lambda:
Mappers
….
….
AWS Lambda:
Reducer
Amazon S3
Results
Serverless batch processing
Best practices and things to think about
• Cascade mapper functions
• Lambda languages vs. SQL
• Speed is directly proportional to the concurrent Lambda function limit
• Use DynamoDB/ElastiCache/S3 for intermediate state of mapper
functions
• Lambda MapReduce Reference Architecture
Costs of serverless batch processing?
• 200 GB normalized Google Ngram data-set
• Serverless:
• 1000 concurrent Lambda invocations
• Processing time: 9 minutes
• Cost: $7.06
Pattern three: stream processing
Characteristics of stream processing
• High ingest rate
• Near real-time processing (low latency from ingest to process)
• Spiky traffic (lots of devices with intermittent network connections)
• Message durability
• Message ordering
Sensors
Amazon Kinesis:
Stream
Lambda:
Stream Processor
S3:
Final Aggregated Output
Lambda:
Periodic Dump to S3
CloudWatch Events:
Trigger every 5 minutes
S3:
Intermediate Aggregated
Data
Lambda:
Scheduled Dispatcher
KPL:
Producer
Serverless stream processing architecture
Fan-out pattern
• Number of Amazon Kinesis Streams shards corresponds to concurrent Lambda invocations
• Trade higher throughput & lower latency vs. strict message ordering
Sensors
Amazon Kinesis:
Stream
Lambda:
Dispatcher
KPL:
Producer Lambda:
Processors
Increase throughput, reduce processing latency
More about fan-out pattern
• Keep up with peak shard capacity
• 1000 records / second, OR
• 1 MB / second
• Consider parallel synchronous Lambda invocations
• Rcoil for JS (https://github.com/sapessi/rcoil) can help
• Dead letter queue to retry failed Lambda invocations
Amazon Kinesis Analytics
Sensors
Amazon Kinesis:
Stream
Amazon Kinesis Analytics:
Window Aggregation
Amazon Kinesis Streams
Producer S3:
Aggregated Output
• CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
• SELECT STREAM "device_id",
• FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE) as "round_ts",
• SUM("measurement") as "sample_sum",
• COUNT(*) AS "sample_count"
• FROM "SOURCE_SQL_STREAM_001"
• GROUP BY "device_id", FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE);
Aggregation Time Window
Some event services options
Amazon Kinesis Streams Amazon SQS Amazon SNS
Message Durability Up to retention period Up to retention period Retry delivery (depends on
destination type)
Maximum Retention Period 7 days 14 days Up to retry delivery limit
Message Ordering Strict within shard Standard - Best effort
FIFO – Strict within Message
Group
None
Delivery semantics Multiple consumers per shard Multiple readers per queue (but
one message is only handled by
one reader at a time)
Multiple subscribers per topic
Scaling By throughput using Shards Automatic Automatic
Iterate over messages Shard iterators No No
Delivery Destination Types Kinesis Consumers SQS Readers HTTP/S, Mobile Push, SMS,
Email, SQS, Lambda
Some serverless streaming best practices
• Tune batch size when Lambda is triggered by Amazon Kinesis Streams – reduce
number of Lambda invocations
• Tune memory setting for your Lambda function – shorten execution time
• Use KPL to batch messages and saturate Amazon Kinesis Stream capacity
Pattern four: automation
Automation characteristics
• Respond to alarms or events
• Periodic jobs
• Auditing and Notification
• Extend AWS functionality
• Highly Available and scalable
AWS Lambda:
Update Route53
Amazon CloudWatch Events:
Rule Triggered
Amazon EC2 Instance
State Changes
Amazon DynamoDB:
EC2 Instance Properties
Amazon Route53:
Private Hosted Zone
Tag:
CNAME = ‘xyz.example.com’
xyz.example.com A 10.2.0.134
Automation: dynamic DNS for EC2 instances
AWS Lambda:
Resize Images
Users upload photos
S3:
Source Bucket
S3:
Destination Bucket
Triggered on
PUTs
Automation: image thumbnail creation from
S3
And now, some words from a special
guest.
Local Lambda celebrity: Randall
But seriously, a few tips from someone who
knows what he’s talking about
• Serverless monolith: frameworks like Zappa or Serverless that just create a single
package and route all requests to the one package
• Easy to port existing applications
• Works well with traditional App level logging and monitoring
• Easy to keep all endpoints warm since everything is hooked up
• Start with a monolith then move out individual endpoints as things break
• If you’re building something greenfield you can do the managed endpoints
pattern with a framework like chalice - each APIGW endpoint gets created, but
it’s still a single app deployment
• Then there’s 1:1 every endpoint gets its own function- makes logging and
introspection a nightmare but gives extreme agility for parallel development
But seriously, a few tips from someone who
knows what he’s talking about
• On the non-web app side: Glue pattern
• Glue is what 99% of lambda deployments are about - taking events from one
service and doing something with them in another
• If services are bricks then lambda is mortar
Other resources
• Randall <3s Lambda!
• @jrhunt on Twitter
• Tons of examples and projects here: https://github.com/ranman
• AWS documentation:
http://docs.aws.amazon.com/lambda/latest/dg/welcome.html
• Tons of compute blog posts:
https://aws.amazon.com/blogs/compute/category/aws-lambda/
• Lambda reference architecture: https://github.com/awslabs/lambda-
refarch-webapp
Thanks!

Mais conteúdo relacionado

Mais procurados

Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...
Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...
Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...Amazon Web Services
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explainedconfluent
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 
Getting Started with AWS Database Migration Service
Getting Started with AWS Database Migration ServiceGetting Started with AWS Database Migration Service
Getting Started with AWS Database Migration ServiceAmazon Web Services
 
Google Cloud Platform Tutorial | GCP Fundamentals | Edureka
Google Cloud Platform Tutorial | GCP Fundamentals | EdurekaGoogle Cloud Platform Tutorial | GCP Fundamentals | Edureka
Google Cloud Platform Tutorial | GCP Fundamentals | EdurekaEdureka!
 
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...HostedbyConfluent
 
Dapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageDapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageBilgin Ibryam
 
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 serversAmazon Web Services
 
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...Amazon Web Services Korea
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021Amazon Web Services Korea
 
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalk
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalkContinuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalk
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalkThomas Shaw
 
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017Amazon Web Services Korea
 
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | Edureka
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | EdurekaCodeBuild CodePipeline CodeDeploy CodeCommit in AWS | Edureka
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | EdurekaEdureka!
 
Introduction to Apache Kafka and Confluent... and why they matter
Introduction to Apache Kafka and Confluent... and why they matterIntroduction to Apache Kafka and Confluent... and why they matter
Introduction to Apache Kafka and Confluent... and why they matterconfluent
 
Redpanda and ClickHouse
Redpanda and ClickHouseRedpanda and ClickHouse
Redpanda and ClickHouseAltinity Ltd
 
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...HostedbyConfluent
 
Introduction to Batch Processing on AWS
Introduction to Batch Processing on AWSIntroduction to Batch Processing on AWS
Introduction to Batch Processing on AWSAmazon Web Services
 

Mais procurados (20)

Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...
Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...
Amazon Virtual Private Cloud (VPC): Networking Fundamentals and Connectivity ...
 
Apache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals ExplainedApache Kafka Architecture & Fundamentals Explained
Apache Kafka Architecture & Fundamentals Explained
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Getting Started with AWS Database Migration Service
Getting Started with AWS Database Migration ServiceGetting Started with AWS Database Migration Service
Getting Started with AWS Database Migration Service
 
Google Cloud Platform Tutorial | GCP Fundamentals | Edureka
Google Cloud Platform Tutorial | GCP Fundamentals | EdurekaGoogle Cloud Platform Tutorial | GCP Fundamentals | Edureka
Google Cloud Platform Tutorial | GCP Fundamentals | Edureka
 
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...
Exposing and Controlling Kafka Event Streaming with Kong Konnect Enterprise |...
 
Introduction to Serverless
Introduction to ServerlessIntroduction to Serverless
Introduction to Serverless
 
Apache Kafka Best Practices
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best Practices
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
 
Dapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any LanguageDapr - A 10x Developer Framework for Any Language
Dapr - A 10x Developer Framework for Any Language
 
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
 
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...
AWS로 데이터 마이그레이션을 위한 방안과 옵션 - 박성훈 스토리지 스페셜리스트 테크니컬 어카운트 매니저, AWS :: AWS Summit...
 
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
AWS를 활용해서 글로벌 게임 런칭하기 - 박진성 AWS 솔루션즈 아키텍트 :: AWS Summit Seoul 2021
 
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalk
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalkContinuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalk
Continuous Delivery using AWS CodePipeline, AWS Lambda & AWS ElasticBeanstalk
 
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
AWS DMS를 통한 오라클 DB 마이그레이션 방법 - AWS Summit Seoul 2017
 
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | Edureka
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | EdurekaCodeBuild CodePipeline CodeDeploy CodeCommit in AWS | Edureka
CodeBuild CodePipeline CodeDeploy CodeCommit in AWS | Edureka
 
Introduction to Apache Kafka and Confluent... and why they matter
Introduction to Apache Kafka and Confluent... and why they matterIntroduction to Apache Kafka and Confluent... and why they matter
Introduction to Apache Kafka and Confluent... and why they matter
 
Redpanda and ClickHouse
Redpanda and ClickHouseRedpanda and ClickHouse
Redpanda and ClickHouse
 
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...
3 Kafka patterns to deliver Streaming Machine Learning models with Andrea Spi...
 
Introduction to Batch Processing on AWS
Introduction to Batch Processing on AWSIntroduction to Batch Processing on AWS
Introduction to Batch Processing on AWS
 

Semelhante a Serverless Architecture Patterns

Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture PatternsAmazon Web Services
 
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
 
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...Amazon Web Services
 
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...Amazon Web Services
 
Serverless Architectural Patterns and Best Practices
Serverless Architectural Patterns and Best PracticesServerless Architectural Patterns and Best Practices
Serverless Architectural Patterns and Best PracticesAmazon Web Services
 
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Amazon Web Services
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
Serverless Architectural Patterns and Best Practices | AWS
Serverless Architectural Patterns and Best Practices | AWSServerless Architectural Patterns and Best Practices | AWS
Serverless Architectural Patterns and Best Practices | AWSAWS Germany
 
Serverless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDBServerless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDBAmazon Web Services
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudIan Massingham
 
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T... Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...Amazon Web Services
 
Big data and serverless - AWS UG The Netherlands
Big data and serverless - AWS UG The NetherlandsBig data and serverless - AWS UG The Netherlands
Big data and serverless - AWS UG The NetherlandsMarek Kuczynski
 
Raleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshopRaleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshopAmazon Web Services
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialMongoDB
 
How to build and deploy serverless apps - AWS Summit Cape Town 2018
How to build and deploy serverless apps - AWS Summit Cape Town 2018How to build and deploy serverless apps - AWS Summit Cape Town 2018
How to build and deploy serverless apps - AWS Summit Cape Town 2018Amazon Web Services
 
NEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeNEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeAmazon Web Services
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaAmazon Web Services
 
AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAmazon Web Services
 
The State of Serverless Computing | AWS Public Sector Summit 2017
The State of Serverless Computing | AWS Public Sector Summit 2017The State of Serverless Computing | AWS Public Sector Summit 2017
The State of Serverless Computing | AWS Public Sector Summit 2017Amazon Web Services
 

Semelhante a Serverless Architecture Patterns (20)

Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
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)
 
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...
AWS re:Invent 2016: [JK REPEAT] Serverless Architectural Patterns and Best Pr...
 
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
AWS re:Invent 2016: Serverless Architectural Patterns and Best Practices (ARC...
 
Serverless Architectural Patterns and Best Practices
Serverless Architectural Patterns and Best PracticesServerless Architectural Patterns and Best Practices
Serverless Architectural Patterns and Best Practices
 
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
Get the EDGE to scale: Using Cloudfront along with edge compute to scale your...
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Serverless Architectural Patterns and Best Practices | AWS
Serverless Architectural Patterns and Best Practices | AWSServerless Architectural Patterns and Best Practices | AWS
Serverless Architectural Patterns and Best Practices | AWS
 
Serverless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDBServerless Web Apps using API Gateway, Lambda and DynamoDB
Serverless Web Apps using API Gateway, Lambda and DynamoDB
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
 
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T... Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
Getting Started with AWS Lambda and the Serverless Cloud - AWS Summit Cape T...
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
Big data and serverless - AWS UG The Netherlands
Big data and serverless - AWS UG The NetherlandsBig data and serverless - AWS UG The Netherlands
Big data and serverless - AWS UG The Netherlands
 
Raleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshopRaleigh DevDay 2017: Build a serverless web application in one day workshop
Raleigh DevDay 2017: Build a serverless web application in one day workshop
 
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas TutorialAWS Lambda, Step Functions & MongoDB Atlas Tutorial
AWS Lambda, Step Functions & MongoDB Atlas Tutorial
 
How to build and deploy serverless apps - AWS Summit Cape Town 2018
How to build and deploy serverless apps - AWS Summit Cape Town 2018How to build and deploy serverless apps - AWS Summit Cape Town 2018
How to build and deploy serverless apps - AWS Summit Cape Town 2018
 
NEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the EdgeNEW LAUNCH! Bringing AWS Lambda to the Edge
NEW LAUNCH! Bringing AWS Lambda to the Edge
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS Lambda
 
AWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the CloudAWS Lambda: Event-driven Code in the Cloud
AWS Lambda: Event-driven Code in the Cloud
 
The State of Serverless Computing | AWS Public Sector Summit 2017
The State of Serverless Computing | AWS Public Sector Summit 2017The State of Serverless Computing | AWS Public Sector Summit 2017
The State of Serverless Computing | AWS Public Sector Summit 2017
 

Mais de 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 FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon 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
 
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 WorkloadsAmazon 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 sfatareAmazon 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 NodeJSAmazon 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 webAmazon 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 sfatareAmazon 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 AWSAmazon 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 DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon 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 ServiceAmazon Web Services
 

Mais de 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
 

Serverless Architecture Patterns

  • 1. Serverless architectural patterns Abby Fuller, AWS @abbyfuller
  • 2. What does serverless mean? No servers to provision or manage Scale with your usage Built in availability and fault- tolerance Never pay for idle/unused capacity
  • 3. Serverless runs on functions • Functions are the unit of deployment and scale • This scales per request! • Skip the boring parts, skip the hard parts
  • 4. Serverless applications FUNCTION SERVICES (ANYTHING) Changes in data state Requests to endpoints Changes in resource state Node Python Java C# EVENT SOURCE
  • 5. Example event sources Data stores Endpoints Configuration repositories Event/message sources Amazon S3 Amazon DynamoDB Amazon Kinesis Amazon Cognito Amazon IoT AWS Step Functions Amazon Alexa AWS CloudTrail AWS CodeCommit Amazon CloudWatch Amazon SES Amazon SNS Cron events Amazon API Gateway AWS Cloudformation …and more!
  • 6. A few Lambda specific best practices • Lambda is stateless  architect accordingly! • Assume no affinity with underlying compute infrastructure • Local filesystem and child processes may not extend beyond the lifetime of the Lambda request
  • 7. Lambda considerations and best practices • Can your Lambda functions survive the cold? • Instantiate AWS clients and database clients outside the scope of the handler to take advantage of connection re-use. • Schedule with CloudWatch Events for warmth • ENIs for VPC support are attached during cold start import sys import logging import rds_config import pymysql rds_host = "rds-instance" db_name = rds_config.db_name try: conn = pymysql.connect( except: logger.error("ERROR: def handler(event, context): with conn.cursor() as cur: Executes during cold start Executes with each invocation
  • 8. Lambda considerations and best practices • How about a file system? • Don’t forget about /tmp (512 MB of scratch space) exports.ffmpeg = function(event,context) { new ffmpeg('./thumb.MP4', function (err, video) { if (!err) { video.fnExtractFrameToJPG('/tmp’) function (error, files) { … } … if (!error) console.log(files); context.done(); ...
  • 9. Lambda considerations and best practices • Custom CloudWatch metrics • 40 KB per POST • Default Acct Limit of 150 TPS • Consider aggregating with Kinesis def put_cstate ( iid, state ): response = cwclient.put_metric_data( Namespace='AWSx/DirectConnect', MetricData=[ { 'MetricName':'ConnectionState', 'Dimensions': [ { 'Name': 'ConnectionId', 'Value': iid }, ], 'Value': state, 'Unit': 'None’
  • 10. A couple kinds of design patterns
  • 11. Pattern one: 3-Tier Web Application
  • 12. 3-Tier web application Browser Amazon CloudFront Amazon S3 Amazon API Gateway Dynamic content in AWS Lambda Data store in Amazon DynamoDB
  • 13. Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon S3 Amazon CloudFront • Bucket Policies • ACLs • OAI • Geo-Restriction • Signed Cookies • Signed URLs • DDOS IAM AuthZ IAM Serverless web app security • Throttling • Caching • Usage Plans Browser
  • 14. Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon S3 Amazon CloudFront • Bucket Policies • ACLs • OAI • Geo-Restriction • Signed Cookies • Signed URLs • DDOS IAMAuthZ IAM Serverless web app security • Throttling • Caching • Usage Plans Browser Amazon CloudFront • HTTPS • Disable Host Header Forwarding AWS WAF
  • 15. Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon S3 Amazon CloudFront • Access Logs in S3 Bucket • Access Logs in S3 Bucket • CloudWatch Metrics- https://aws.amazon.com/clo udfront/reporting/ Serverless web app monitoring AWS WAF • WebACL Testing • Total Requests • Allowed/Blocked Requests by ACL logslogs • Invocations • Invocation Errors • Duration • Throttled Invocations • Latency • Throughput • Throttled Reqs • Returned Bytes • Documentation • Latency • Count • Cache Hit/Miss • 4XX/5XX Errors Streams AWS CloudTrail Browser Custom CloudWatch Metrics & Alarms
  • 16. Serverless web app lifecycle management • AWS SAM (Serverless Application Model) - blog AWS Lambda Amazon API Gateway AWS CloudFormationAmazon S3 Amazon DynamoDB Package & Deploy Code/Packages/Swagger Serverless Template Serverless Template w/ CodeUri package deploy CI/CD Tools
  • 17. A couple words on Amazon API Gateway • Use mock integrations • Signed URL from API Gateway for large or binary file uploads to S3 • Use request/response mapping templates for legacy apps and HTTP response codes • Asynchronous calls for Lambda > 30s
  • 18. Root/ /{proxy+} ANY Node.js Express app • Simple yet very powerful: • Automatically scale to meet demand • Only pay for the requests you receive Greedy variable, ANY method, proxy integration
  • 19. Pattern two: Batch processing
  • 20. Characteristics of batch processing • Large data sets • Periodic or scheduled tasks • Extract Transform Load (ETL) jobs • Usually non-interactive and long running • Many problems fit MapReduce programming model
  • 21. AWS Lambda: Splitter Amazon S3 Object Amazon DynamoDB: Mapper Results AWS Lambda: Mappers …. …. AWS Lambda: Reducer Amazon S3 Results Serverless batch processing
  • 22. Best practices and things to think about • Cascade mapper functions • Lambda languages vs. SQL • Speed is directly proportional to the concurrent Lambda function limit • Use DynamoDB/ElastiCache/S3 for intermediate state of mapper functions • Lambda MapReduce Reference Architecture
  • 23. Costs of serverless batch processing? • 200 GB normalized Google Ngram data-set • Serverless: • 1000 concurrent Lambda invocations • Processing time: 9 minutes • Cost: $7.06
  • 24. Pattern three: stream processing
  • 25. Characteristics of stream processing • High ingest rate • Near real-time processing (low latency from ingest to process) • Spiky traffic (lots of devices with intermittent network connections) • Message durability • Message ordering
  • 26. Sensors Amazon Kinesis: Stream Lambda: Stream Processor S3: Final Aggregated Output Lambda: Periodic Dump to S3 CloudWatch Events: Trigger every 5 minutes S3: Intermediate Aggregated Data Lambda: Scheduled Dispatcher KPL: Producer Serverless stream processing architecture
  • 27. Fan-out pattern • Number of Amazon Kinesis Streams shards corresponds to concurrent Lambda invocations • Trade higher throughput & lower latency vs. strict message ordering Sensors Amazon Kinesis: Stream Lambda: Dispatcher KPL: Producer Lambda: Processors Increase throughput, reduce processing latency
  • 28. More about fan-out pattern • Keep up with peak shard capacity • 1000 records / second, OR • 1 MB / second • Consider parallel synchronous Lambda invocations • Rcoil for JS (https://github.com/sapessi/rcoil) can help • Dead letter queue to retry failed Lambda invocations
  • 29. Amazon Kinesis Analytics Sensors Amazon Kinesis: Stream Amazon Kinesis Analytics: Window Aggregation Amazon Kinesis Streams Producer S3: Aggregated Output • CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM" • SELECT STREAM "device_id", • FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE) as "round_ts", • SUM("measurement") as "sample_sum", • COUNT(*) AS "sample_count" • FROM "SOURCE_SQL_STREAM_001" • GROUP BY "device_id", FLOOR("SOURCE_SQL_STREAM_001".ROWTIME TO MINUTE); Aggregation Time Window
  • 30. Some event services options Amazon Kinesis Streams Amazon SQS Amazon SNS Message Durability Up to retention period Up to retention period Retry delivery (depends on destination type) Maximum Retention Period 7 days 14 days Up to retry delivery limit Message Ordering Strict within shard Standard - Best effort FIFO – Strict within Message Group None Delivery semantics Multiple consumers per shard Multiple readers per queue (but one message is only handled by one reader at a time) Multiple subscribers per topic Scaling By throughput using Shards Automatic Automatic Iterate over messages Shard iterators No No Delivery Destination Types Kinesis Consumers SQS Readers HTTP/S, Mobile Push, SMS, Email, SQS, Lambda
  • 31. Some serverless streaming best practices • Tune batch size when Lambda is triggered by Amazon Kinesis Streams – reduce number of Lambda invocations • Tune memory setting for your Lambda function – shorten execution time • Use KPL to batch messages and saturate Amazon Kinesis Stream capacity
  • 33. Automation characteristics • Respond to alarms or events • Periodic jobs • Auditing and Notification • Extend AWS functionality • Highly Available and scalable
  • 34. AWS Lambda: Update Route53 Amazon CloudWatch Events: Rule Triggered Amazon EC2 Instance State Changes Amazon DynamoDB: EC2 Instance Properties Amazon Route53: Private Hosted Zone Tag: CNAME = ‘xyz.example.com’ xyz.example.com A 10.2.0.134 Automation: dynamic DNS for EC2 instances
  • 35. AWS Lambda: Resize Images Users upload photos S3: Source Bucket S3: Destination Bucket Triggered on PUTs Automation: image thumbnail creation from S3
  • 36. And now, some words from a special guest.
  • 38.
  • 39. But seriously, a few tips from someone who knows what he’s talking about • Serverless monolith: frameworks like Zappa or Serverless that just create a single package and route all requests to the one package • Easy to port existing applications • Works well with traditional App level logging and monitoring • Easy to keep all endpoints warm since everything is hooked up • Start with a monolith then move out individual endpoints as things break • If you’re building something greenfield you can do the managed endpoints pattern with a framework like chalice - each APIGW endpoint gets created, but it’s still a single app deployment • Then there’s 1:1 every endpoint gets its own function- makes logging and introspection a nightmare but gives extreme agility for parallel development
  • 40. But seriously, a few tips from someone who knows what he’s talking about • On the non-web app side: Glue pattern • Glue is what 99% of lambda deployments are about - taking events from one service and doing something with them in another • If services are bricks then lambda is mortar
  • 41. Other resources • Randall <3s Lambda! • @jrhunt on Twitter • Tons of examples and projects here: https://github.com/ranman • AWS documentation: http://docs.aws.amazon.com/lambda/latest/dg/welcome.html • Tons of compute blog posts: https://aws.amazon.com/blogs/compute/category/aws-lambda/ • Lambda reference architecture: https://github.com/awslabs/lambda- refarch-webapp