SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless Architectural Patterns
Pawan Puthran
Snr. Technical Account Manager
Amazon Web Services
@pawanputhran
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Agenda
• Serverless Foundation
• Web application
• Data Lake
• Stream processing
• Operations automation
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A serverless world…
Build and run
applications
without thinking about
servers
… pay per request not
for idle
“ Scales with usage High availability
built-in
Never pay for idle No servers
to provision
or manage
”
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Building blocks for serverless applications
AWS Lambda
Amazon DynamoDB
Amazon SNS
Amazon API Gateway Amazon SQS Amazon Kinesis
Amazon S3
Orchestration and State Management
API Proxy and GraphQL Messaging and Queues Analytics
Monitoring and Debugging
Compute Storage Database
AWS X-RayAWS Step Functions Amazon Cognito
User Management and IdP
AWS AppSync Amazon Athena
AWS Lambda@Edge
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS X-Ray Integration with Serverless
• Lambda instruments incoming
requests for all supported languages
• Lambda runs the X-Ray daemon on all
languages with an SDK
const AWSXRay = require(‘aws-xray-sdk-core‘);
AWSXRay.middleware.setSamplingRules(‘sampling-rules.json’);
const AWS = AWSXRay.captureAWS(require(‘aws-sdk’));
S3Client = AWS.S3();
AWS X-Ray Now Supports Amazon API Gateway (NEW)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
X-Ray Trace Example
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Serverless Application Model (SAM)
• CloudFormation extension optimized for
serverless
• New serverless resource types: functions,
APIs, and tables
• Supports anything CloudFormation
supports
• Open specification (Apache 2.0)
• SAM Translator recently open sourced.
https://github.com/awslabs/serverless-application-model
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAM CLI
• Develop and test Lambda locally
• Invoke functions with mock
serverless events
• Local template validation
• Local API Gateway with hot
reloading
https://github.com/awslabs/aws-sam-cli
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Delivery via CodePipeline
Pipeline flow:
1. Commit your code to a source code repository
2. Package/test in CodeBuild
3. Use CloudFormation actions in CodePipeline to create
or update stacks via SAM templates
Optional: Make use of ChangeSets
4. Make use of specific stage/environment parameter files
to pass in Lambda variables
5. Test our application between stages/environments
Optional: Make use of manual approvals
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS CodeDeploy and Lambda Canary Deployments
• Direct a portion of traffic to a
new version
• Monitor stability with
CloudWatch
• Initiate rollback if needed
• Incorporate into your SAM
templates
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Lambda Best Practices
• Minimize package size to necessities
• Separate the Lambda handler from core logic
• Use Environment Variables to modify operational behavior
• Self-contain dependencies in your function package
• Leverage “Max Memory Used” to right-size your functions
• Delete large unused functions (75GB limit)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pattern 1:
Web App/Microservice/API
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Web application
Data stored in
Amazon
DynamoDB
Dynamic content
in AWS Lambda
Amazon API
Gateway
Browser
Amazon
CloudFront
Amazon
S3
Amazon Cognito
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Bustle Achieves 84% Cost Savings with AWS Lambda
Bustle is a news, entertainment, lifestyle, and fashion
website targeted towards women.
With AWS Lambda, we
eliminate the need to worry
about operations
Tyler Love
CTO, Bustle
”
“ • Bustle had trouble scaling and
maintaining high availability for its
website without heavy management
• Moved to serverless architecture using
AWS Lambda and Amazon API
Gateway
• Experienced approximately 84% in
cost savings
• Engineers are now focused on
innovation
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon API
Gateway AWS
Lambda
Amazon
DynamoDB
Amazon
S3
Amazon
CloudFront
• Bucket Policies
• ACLs
• Origin Access Identity (OAI)
• Geo-Restriction
• Signed Cookies
• Signed URLs
• DDOS Protection
IAM
AuthZ
IAM
Serverless web app security
• Throttling
• Caching
• Usage Plans
• ACM
Browser
Amazon Cognito
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Authorization with Amazon Cognito
Cognito User Pool
(CUP)
Amazon API Gateway
Web Identity
Provider
User A
User B
User C
Cognito Identity Pool
(CIP)
/web
/cip
/cup
AWS
Lambda
Amazon
DynamoDB
Token
AWS Credentials
User B Data
IAM
Authorization
API Resources
C C
A A
A
B
BB
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Custom
Authorizer
Lambda
functionClient
Lambda
function
Amazon API
Gateway
Amazon
DynamoDB
AWS Identity &
Access Management
SAML
Two types:
• TOKEN - authorization token
passed in a header
• REQUEST – all headers, query
strings, paths, stage variables or
context variables.
Custom Authorizers
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Multi-Region with API Gateway
eu-central-2
eu-west-1
Client
Amazon
Route 53
Regional
API
Endpoint
Regional
API
Endpoint
Custom
Domain
Name
Custom
Domain
Name
API Gateway
API Gateway
Lambda
Lambda
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Useful Frameworks for Serverless Web Apps
• AWS Chalice
Python Serverless Framework
https://github.com/aws/chalice
Familiar decorator-based API similar to Flask/Bottle
Similar to third-party frameworks, Zappa or Claudia.js
• AWS Serverless Express
Run Node.js Express apps
https://github.com/awslabs/aws-serverless-express
• Java - HttpServlet, Spring, Spark and Jersey
https://github.com/awslabs/aws-serverless-java-container
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pattern 2:
Data Lake
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless Data Lake Characteristics
• Collect/Store/Process/Consume and Analyze all
organizational data
• Structured/Semi-Structured/Unstructured data
• AI/ML and BI/Analytical use cases
• Fast automated ingestion
• Schema on Read
• Complementary to EDW
• Decoupled Compute and Storage
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Serverless Data Lake
S3
Bucket(s)
Key
Management
Service
Amazon
Athena
AWS
CloudTrail
Amazon
Cognito
AWS IAM
Amazon
Kinesis
Streams
Amazon
Kinesis
Firehose
Amazon ES
Amazon
QuickSight
AWS Glue
Amazon
DynamoDB
Amazon
Macie
Amazon API
Gateway
AWS IAM
Amazon
Redshift
Spectrum
AWS
Direct
Connect
Ingest
Catalog & Search
Security & Auditing
API/UI
Analytics & Processing
AWS Glue
AWS
Lambda
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
The Foundation…Amazon S3
• No need to run compute
clusters for storage
• Virtually unlimited number of
objects and volume
• Very high bandwidth – no
aggregate throughput limit
• Multiple storage classes
• Versioning
• Encryption
• AWS CloudTrail Data Events
• S3 Analytics and Inventory
• AWS Config automated checks
• S3 Object Tagging
• S3 Select (NEW!)
• Glacier Select (NEW!)
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Search and Data Catalog
• DynamoDB as
Metadata repository
• Amazon Elasticsearch
Catalog & Search
AWS Lambda
AWS Lambda
Metadata Index
(DynamoDB)
Search Index
(Amazon ES)
ObjectCreated
ObjectDeleted PutItem
Update Stream
Update Index
Extract Search Fields
S3 Bucket
https://aws.amazon.com/answers/big-data/data-lake-solution/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Glue
Crawlers
AWS Glue
Data Catalog
Amazon
QuickSight
Amazon
Redshift
Spectrum
Amazon
Athena
S3
Bucket(s)
Catalog & Search
Instantly query your data lake on Amazon S3
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Analytics and Processing
• Amazon QuickSight
• Amazon Athena
• AWS Lambda
• Predictive Analytics
• Amazon EMR
• AWS Glue (ETL)
Analytics & Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Athena – Serverless Interactive Query Service
SELECT gram, year, sum(count) FROM ngram
WHERE gram = 'just say no'
GROUP BY gram,year ORDER BY year ASC;
44.66 seconds...Data scanned: 169.53GB
Cost: $5/TB or $0.005/GB = $0.85
Analytics & Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Athena – Best Practices
• Partition data
s3://bucket/flight/parquet/year=1991/month=1/day=2/
• Columnar formats – Apache Parquet, AVRO, ORC
• Compress files with splittable compression (bzip2)
• Optimize file sizes
https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/
Analytics & Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless batch processing
AWS Lambda:
Splitter
Amazon S3
Object
Amazon DynamoDB:
Mapper Results
AWS Lambda:
Mappers
….
….
AWS Lambda:
Reducer
Amazon S3
Results
Analytics & Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fannie Mae Serverless Financial Modeling
Financial Modeling is a Monte-Carlo simulation process to project future cash flows , which is
used for managing the mortgage risk on daily basis:
• Underwriting and valuation
• Risk management
• Financial reporting
• Loss mitigation and loan removal
• ~10 Quadrillion (10𝑥1015
) of cash flow
projections each month in hundreds
of economic scenarios.
• One simulation run of ~ 20 million
mortgages takes 1.4 hours, >4 times
faster than the existing process.
Federal National Mortgage Association
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pywren
• Pywren Python library provides 10 TFLOPS of peak compute
power with new default – 1,000 concurrent functions
• Achieve over 60 GB/sec of read and 50 GB/sec of write
performance using Amazon S3
https://pywren.io
Analytics & Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pattern 3:
Stream Processing
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Stream processing characteristics
• 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
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Streaming data ingestion
Amazon CloudWatch:
Delivery metrics
Amazon S3:
Buffered files
Kinesis
Agent
Record
Producers Amazon Redshift:
Table loads
Amazon Elasticsearch Service:
Domain loads
Amazon S3:
Source record backup
AWS Lambda:
Transformations &
enrichment
Amazon DynamoDB:
Lookup tables
Raw records
Lookup
Transformed records
Transformed recordsRaw records
Amazon Kinesis Firehose:
Delivery stream
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best practices
• Tune Firehose buffer size and buffer interval
• Larger objects = fewer Lambda invocations, fewer S3 PUTs
• Enable compression to reduce storage costs
• Enable Source Record Backup for transformations
• Recover from transformation errors
• Follow Amazon Redshift Best Practices for Loading Data
• How to handle time series, sorted data
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Sensor data collection
IoT
rules
IoT
actions
MQTT
Amazon S3:
Raw records
Amazon Kinesis Firehose:
Delivery stream
Amazon S3:
Batched records
Amazon Kinesis Streams:
Real-time stream
AWS IoT:
Data collection
IoT Sensors
Real-time analytics
applications
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Real-time analytics
Amazon Kinesis Streams:
Ingest stream
Amazon Kinesis Analytics:
Time window aggregation
Amazon Kinesis Streams:
Aggregates stream
Amazon Kinesis Firehose:
Error stream
Amazon S3:
Error records
Record
Producers
AWS Lambda:
Alert function
Amazon DynamoDB:
Device thresholds
AWS SNS:
Notifications
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Kinesis Analytics
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
SELECT STREAM "device_id",
STEP("SOURCE_SQL_STREAM_001".ROWTIME BY INTERVAL '1' MINUTE) as "window_ts",
SUM("measurement") as "sample_sum",
COUNT(*) AS "sample_count"
FROM "SOURCE_SQL_STREAM_001"
GROUP BY "device_id",
STEP("SOURCE_SQL_STREAM_001".ROWTIME BY INTERVAL '1' MINUTE);
Aggregation
1-minute tumbling window
Amazon Kinesis Analytics:
Time window aggregation
Source stream Destination stream
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Real-time analytics
Amazon Kinesis Streams:
Ingest stream
Amazon Kinesis Analytics:
Time window aggregation
Amazon Kinesis Streams:
Aggregates stream
Amazon Kinesis Firehose:
Error stream
Amazon S3:
Error records
Record
Producers
AWS Lambda:
Alert function
Amazon DynamoDB:
Device thresholds
AWS SNS:
Notifications
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Amazon Kinesis Streams and AWS Lambda
• Number of Amazon Kinesis Streams shards corresponds to concurrent invocations
of Lambda function
• Batch size sets maximum number of records per Lambda function invocation
Amazon Kinesis:
Stream
AWS Lambda:
Processor function
Streaming source Other AWS services
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Fan-out pattern
Fan-out pattern trades strict message ordering vs higher throughput & lower latency
Amazon Kinesis:
Stream
Lambda:
Dispatcher function
Lambda:
Processor function
Increase throughput, reduce processing latency
Streaming source
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thomson Reuters – Product Insight
Solution for usage analysis tracking:
Capture, analyze, and visualize analytics data generated by offerings, providing
insights to help product teams continuously improve the user experience
Throughput: Tested 4,000 requests / second
Growing to 10,000 requests / second or 25 Billion requests / month
Latency: new events to user dashboards in less than 10 seconds
Durable: no data loss since inception
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best practices
• Tune batch size when Lambda is triggered by Amazon Kinesis Streams
• Higher batch size = fewer Lambda invocations
• Tune memory setting for your Lambda function
• Higher memory = shorter execution time
• Use Kinesis Producer Library (KPL) to batch messages and saturate
Amazon Kinesis Stream capacity
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Pattern 4:
Operations Automation
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Automation characteristics
• Periodic jobs
• Event triggered workflows
• Enforce security policies
• Audit and notification
• Respond to alarms
• Extend AWS functionality
… All while being Highly Available, Scalable and Auditable
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Ops Automator
Amazon CloudWatch:
Time-based events
AWS Lambda:
Event handler
AWS Lambda:
Task executors
AWS SNS:
Error and warning notifications
Resources in multiple AWS
Regions and Accounts
Amazon EC2 Instances
Tags
OpsAutomatorTaskList CreateSnapshotAmazon DynamoDB:
Task configuration & tracking
Amazon CloudWatch:
Logs
Amazon Redshift Clusters
https://aws.amazon.com/answers/infrastructure-management/ops-automator/
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Image recognition and processing
Web App
Amazon DynamoDB:
Image meta-data & tags
Amazon Cognito:
User authentication
Amazon S3:
Image uploads
AWS Step Functions:
Workflow orchestration
Start state machine execution
1
Extract image meta-data
2
Amazon Rekognition:
Object detection
Invoke Amazon Rekognition
Generate image thumbnail
3
3Store meta-data and tags
4
https://github.com/awslabs/lambda-refarch-imagerecognition
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Step Functions state machine
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Enforce security policies
RDP from
0.0.0.0/0
RDP from
0.0.0.0/0
CloudWatch Event Bus in
another AWS Account
New Security Group ingress rule Amazon CloudWatch Events:
Rule
AWS Lambda:
Remediate and alert
AWS SNS:
Email alert
Ingress rule deleted
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Autodesk - Tailor
Serverless AWS Account Provisioning and Management Service:
• Automates AWS Account creation,
• Configures IAM, CloudTrail, AWS Config, Direct Connect, and VPC
• Enforces corporate standards
• Audit for compliance
Provisions new Accounts in 10 minutes vs 10 hours in earlier manual process
Open source and extensible: https://github.com/alanwill/aws-tailor
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Best practices
• Gracefully handle API throttling by retrying with an exponential back-off
algorithm (AWS SDKs do this for you)
• Publish custom metrics from your Lambda function that are meaningful for
operations (e.g. number of EBS volumes snapshotted)
• Enable X-Ray tracing for your Lambda functions
• Document how to disable event triggers for your automation when
troubleshooting
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Summary
Use DevOps tools to automate your serverless deployments
Apply serverless patterns for common use-cases:
• Web application
• Data Lake Foundation
• Stream processing
• Operations automation
What will you build with Serverless?
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Further Reading
• Optimizing Enterprise Economics with Serverless Architectures
https://d0.awsstatic.com/whitepapers/optimizing-enterprise-economics-serverless-architectures.pdf
• Serverless Architectures with AWS Lambda
https://d1.awsstatic.com/whitepapers/serverless-architectures-with-aws-lambda.pdf
• Serverless Applications Lens - AWS Well-Architected Framework
https://d1.awsstatic.com/whitepapers/architecture/AWS-Serverless-Applications-Lens.pdf
• Streaming Data Solutions on AWS with Amazon Kinesis
https://d1.awsstatic.com/whitepapers/whitepaper-streaming-data-solutions-on-aws-with-amazon-kinesis.pdf
• AWS Serverless Multi-Tier Architectures
https://d1.awsstatic.com/whitepapers/AWS_Serverless_Multi-Tier_Archiectures.pdf
© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank You!
Pawan Puthran
Snr. Technical Account Manager
@pawanputhran

Mais conteúdo relacionado

Mais procurados

Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017
Amazon Web Services
 
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Amazon Web Services
 

Mais procurados (20)

Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
Build and Deploy Serverless Applications with AWS SAM - SRV316 - Chicago AWS ...
 
What's New with AWS Lambda
What's New with AWS LambdaWhat's New with AWS Lambda
What's New with AWS Lambda
 
Serverless Architectures.pdf
Serverless Architectures.pdfServerless Architectures.pdf
Serverless Architectures.pdf
 
Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28Introduction to Serverless computing and AWS Lambda - Floor28
Introduction to Serverless computing and AWS Lambda - Floor28
 
Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017Building Serverless Web Applications - DevDay Austin 2017
Building Serverless Web Applications - DevDay Austin 2017
 
Getting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless ComputingGetting Started with AWS Lambda Serverless Computing
Getting Started with AWS Lambda Serverless Computing
 
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)
 
Serverless computing with AWS Lambda
Serverless computing with AWS Lambda Serverless computing with AWS Lambda
Serverless computing with AWS Lambda
 
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
Building CICD Pipelines for Serverless Applications - DevDay Austin 2017
 
Serverless architecture
Serverless architectureServerless architecture
Serverless architecture
 
Introduction to the Serverless Cloud
Introduction to the Serverless CloudIntroduction to the Serverless Cloud
Introduction to the Serverless Cloud
 
把您的 Amazon Lex Chatbot 與訊息服務集成
把您的 Amazon Lex Chatbot 與訊息服務集成把您的 Amazon Lex Chatbot 與訊息服務集成
把您的 Amazon Lex Chatbot 與訊息服務集成
 
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
 
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 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 Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless CloudAWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
AWS Summit Auckland - Getting Started with AWS Lambda and the Serverless Cloud
 
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
Getting Started with Serverless Architectures | AWS Public Sector Summit 2016
 
10 Tips For Serverless Backends With NodeJS and AWS Lambda
10 Tips For Serverless Backends With NodeJS and AWS Lambda10 Tips For Serverless Backends With NodeJS and AWS Lambda
10 Tips For Serverless Backends With NodeJS and AWS Lambda
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
 

Semelhante a Serverless Architectural Patterns

Semelhante a Serverless Architectural Patterns (20)

Getting Started with Serverless Architectures
Getting Started with Serverless ArchitecturesGetting Started with Serverless Architectures
Getting Started with Serverless Architectures
 
Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018Serverless Architectural Patterns: Collision 2018
Serverless Architectural Patterns: Collision 2018
 
Serverless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless EventServerless use cases with AWS Lambda - More Serverless Event
Serverless use cases with AWS Lambda - More Serverless Event
 
Building Serverless Applications with Amazon DynamoDB & AWS Lambda - Workshop...
Building Serverless Applications with Amazon DynamoDB & AWS Lambda - Workshop...Building Serverless Applications with Amazon DynamoDB & AWS Lambda - Workshop...
Building Serverless Applications with Amazon DynamoDB & AWS Lambda - Workshop...
 
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
 
Wildrydes Serverless Workshop Tel Aviv
Wildrydes Serverless Workshop Tel AvivWildrydes Serverless Workshop Tel Aviv
Wildrydes Serverless Workshop Tel Aviv
 
Serverless Architectural Patterns and Best Practices (ARC305-R2) - AWS re:Inv...
Serverless Architectural Patterns and Best Practices (ARC305-R2) - AWS re:Inv...Serverless Architectural Patterns and Best Practices (ARC305-R2) - AWS re:Inv...
Serverless Architectural Patterns and Best Practices (ARC305-R2) - AWS re:Inv...
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
Build Enterprise-Grade Serverless Apps
Build Enterprise-Grade Serverless Apps Build Enterprise-Grade Serverless Apps
Build Enterprise-Grade Serverless Apps
 
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWSServerless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
 
Forza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessForza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni Serverless
 
AWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day IsraelAWS Lambda use cases and best practices - Builders Day Israel
AWS Lambda use cases and best practices - Builders Day Israel
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
Scaling from zero to millions of users
Scaling from zero to millions of usersScaling from zero to millions of users
Scaling from zero to millions of users
 
Serverless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best PracticesServerless on AWS: Architectural Patterns and Best Practices
Serverless on AWS: Architectural Patterns and Best Practices
 
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
 
SRV315 Building Enterprise-Grade Serverless Apps
 SRV315 Building Enterprise-Grade Serverless Apps SRV315 Building Enterprise-Grade Serverless Apps
SRV315 Building Enterprise-Grade Serverless Apps
 
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
 
Serverless Development Deep Dive
Serverless Development Deep DiveServerless Development Deep Dive
Serverless Development Deep Dive
 
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
Build Modern Applications that Align with Twelve-Factor Methods (API303) - AW...
 

Mais de Amazon Web Services

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

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 Architectural Patterns

  • 1. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless Architectural Patterns Pawan Puthran Snr. Technical Account Manager Amazon Web Services @pawanputhran
  • 2. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Agenda • Serverless Foundation • Web application • Data Lake • Stream processing • Operations automation
  • 3. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A serverless world… Build and run applications without thinking about servers … pay per request not for idle “ Scales with usage High availability built-in Never pay for idle No servers to provision or manage ”
  • 4. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Building blocks for serverless applications AWS Lambda Amazon DynamoDB Amazon SNS Amazon API Gateway Amazon SQS Amazon Kinesis Amazon S3 Orchestration and State Management API Proxy and GraphQL Messaging and Queues Analytics Monitoring and Debugging Compute Storage Database AWS X-RayAWS Step Functions Amazon Cognito User Management and IdP AWS AppSync Amazon Athena AWS Lambda@Edge
  • 5. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS X-Ray Integration with Serverless • Lambda instruments incoming requests for all supported languages • Lambda runs the X-Ray daemon on all languages with an SDK const AWSXRay = require(‘aws-xray-sdk-core‘); AWSXRay.middleware.setSamplingRules(‘sampling-rules.json’); const AWS = AWSXRay.captureAWS(require(‘aws-sdk’)); S3Client = AWS.S3(); AWS X-Ray Now Supports Amazon API Gateway (NEW)
  • 6. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. X-Ray Trace Example
  • 7. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Serverless Application Model (SAM) • CloudFormation extension optimized for serverless • New serverless resource types: functions, APIs, and tables • Supports anything CloudFormation supports • Open specification (Apache 2.0) • SAM Translator recently open sourced. https://github.com/awslabs/serverless-application-model
  • 8. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAM CLI • Develop and test Lambda locally • Invoke functions with mock serverless events • Local template validation • Local API Gateway with hot reloading https://github.com/awslabs/aws-sam-cli
  • 9. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Delivery via CodePipeline Pipeline flow: 1. Commit your code to a source code repository 2. Package/test in CodeBuild 3. Use CloudFormation actions in CodePipeline to create or update stacks via SAM templates Optional: Make use of ChangeSets 4. Make use of specific stage/environment parameter files to pass in Lambda variables 5. Test our application between stages/environments Optional: Make use of manual approvals
  • 10. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS CodeDeploy and Lambda Canary Deployments • Direct a portion of traffic to a new version • Monitor stability with CloudWatch • Initiate rollback if needed • Incorporate into your SAM templates
  • 11. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Lambda Best Practices • Minimize package size to necessities • Separate the Lambda handler from core logic • Use Environment Variables to modify operational behavior • Self-contain dependencies in your function package • Leverage “Max Memory Used” to right-size your functions • Delete large unused functions (75GB limit)
  • 12. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pattern 1: Web App/Microservice/API
  • 13. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Web application Data stored in Amazon DynamoDB Dynamic content in AWS Lambda Amazon API Gateway Browser Amazon CloudFront Amazon S3 Amazon Cognito
  • 14. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Bustle Achieves 84% Cost Savings with AWS Lambda Bustle is a news, entertainment, lifestyle, and fashion website targeted towards women. With AWS Lambda, we eliminate the need to worry about operations Tyler Love CTO, Bustle ” “ • Bustle had trouble scaling and maintaining high availability for its website without heavy management • Moved to serverless architecture using AWS Lambda and Amazon API Gateway • Experienced approximately 84% in cost savings • Engineers are now focused on innovation
  • 15. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon API Gateway AWS Lambda Amazon DynamoDB Amazon S3 Amazon CloudFront • Bucket Policies • ACLs • Origin Access Identity (OAI) • Geo-Restriction • Signed Cookies • Signed URLs • DDOS Protection IAM AuthZ IAM Serverless web app security • Throttling • Caching • Usage Plans • ACM Browser Amazon Cognito
  • 16. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Authorization with Amazon Cognito Cognito User Pool (CUP) Amazon API Gateway Web Identity Provider User A User B User C Cognito Identity Pool (CIP) /web /cip /cup AWS Lambda Amazon DynamoDB Token AWS Credentials User B Data IAM Authorization API Resources C C A A A B BB
  • 17. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Custom Authorizer Lambda functionClient Lambda function Amazon API Gateway Amazon DynamoDB AWS Identity & Access Management SAML Two types: • TOKEN - authorization token passed in a header • REQUEST – all headers, query strings, paths, stage variables or context variables. Custom Authorizers
  • 18. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Multi-Region with API Gateway eu-central-2 eu-west-1 Client Amazon Route 53 Regional API Endpoint Regional API Endpoint Custom Domain Name Custom Domain Name API Gateway API Gateway Lambda Lambda
  • 19. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Useful Frameworks for Serverless Web Apps • AWS Chalice Python Serverless Framework https://github.com/aws/chalice Familiar decorator-based API similar to Flask/Bottle Similar to third-party frameworks, Zappa or Claudia.js • AWS Serverless Express Run Node.js Express apps https://github.com/awslabs/aws-serverless-express • Java - HttpServlet, Spring, Spark and Jersey https://github.com/awslabs/aws-serverless-java-container
  • 20. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pattern 2: Data Lake
  • 21. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless Data Lake Characteristics • Collect/Store/Process/Consume and Analyze all organizational data • Structured/Semi-Structured/Unstructured data • AI/ML and BI/Analytical use cases • Fast automated ingestion • Schema on Read • Complementary to EDW • Decoupled Compute and Storage
  • 22. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Serverless Data Lake S3 Bucket(s) Key Management Service Amazon Athena AWS CloudTrail Amazon Cognito AWS IAM Amazon Kinesis Streams Amazon Kinesis Firehose Amazon ES Amazon QuickSight AWS Glue Amazon DynamoDB Amazon Macie Amazon API Gateway AWS IAM Amazon Redshift Spectrum AWS Direct Connect Ingest Catalog & Search Security & Auditing API/UI Analytics & Processing AWS Glue AWS Lambda
  • 23. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. The Foundation…Amazon S3 • No need to run compute clusters for storage • Virtually unlimited number of objects and volume • Very high bandwidth – no aggregate throughput limit • Multiple storage classes • Versioning • Encryption • AWS CloudTrail Data Events • S3 Analytics and Inventory • AWS Config automated checks • S3 Object Tagging • S3 Select (NEW!) • Glacier Select (NEW!)
  • 24. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Search and Data Catalog • DynamoDB as Metadata repository • Amazon Elasticsearch Catalog & Search AWS Lambda AWS Lambda Metadata Index (DynamoDB) Search Index (Amazon ES) ObjectCreated ObjectDeleted PutItem Update Stream Update Index Extract Search Fields S3 Bucket https://aws.amazon.com/answers/big-data/data-lake-solution/
  • 25. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Glue Crawlers AWS Glue Data Catalog Amazon QuickSight Amazon Redshift Spectrum Amazon Athena S3 Bucket(s) Catalog & Search Instantly query your data lake on Amazon S3
  • 26. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Analytics and Processing • Amazon QuickSight • Amazon Athena • AWS Lambda • Predictive Analytics • Amazon EMR • AWS Glue (ETL) Analytics & Processing
  • 27. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Athena – Serverless Interactive Query Service SELECT gram, year, sum(count) FROM ngram WHERE gram = 'just say no' GROUP BY gram,year ORDER BY year ASC; 44.66 seconds...Data scanned: 169.53GB Cost: $5/TB or $0.005/GB = $0.85 Analytics & Processing
  • 28. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Athena – Best Practices • Partition data s3://bucket/flight/parquet/year=1991/month=1/day=2/ • Columnar formats – Apache Parquet, AVRO, ORC • Compress files with splittable compression (bzip2) • Optimize file sizes https://aws.amazon.com/blogs/big-data/top-10-performance-tuning-tips-for-amazon-athena/ Analytics & Processing
  • 29. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless batch processing AWS Lambda: Splitter Amazon S3 Object Amazon DynamoDB: Mapper Results AWS Lambda: Mappers …. …. AWS Lambda: Reducer Amazon S3 Results Analytics & Processing
  • 30. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Fannie Mae Serverless Financial Modeling Financial Modeling is a Monte-Carlo simulation process to project future cash flows , which is used for managing the mortgage risk on daily basis: • Underwriting and valuation • Risk management • Financial reporting • Loss mitigation and loan removal • ~10 Quadrillion (10𝑥1015 ) of cash flow projections each month in hundreds of economic scenarios. • One simulation run of ~ 20 million mortgages takes 1.4 hours, >4 times faster than the existing process. Federal National Mortgage Association
  • 31. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pywren • Pywren Python library provides 10 TFLOPS of peak compute power with new default – 1,000 concurrent functions • Achieve over 60 GB/sec of read and 50 GB/sec of write performance using Amazon S3 https://pywren.io Analytics & Processing
  • 32. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pattern 3: Stream Processing
  • 33. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Stream processing characteristics • 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
  • 34. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Streaming data ingestion Amazon CloudWatch: Delivery metrics Amazon S3: Buffered files Kinesis Agent Record Producers Amazon Redshift: Table loads Amazon Elasticsearch Service: Domain loads Amazon S3: Source record backup AWS Lambda: Transformations & enrichment Amazon DynamoDB: Lookup tables Raw records Lookup Transformed records Transformed recordsRaw records Amazon Kinesis Firehose: Delivery stream
  • 35. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best practices • Tune Firehose buffer size and buffer interval • Larger objects = fewer Lambda invocations, fewer S3 PUTs • Enable compression to reduce storage costs • Enable Source Record Backup for transformations • Recover from transformation errors • Follow Amazon Redshift Best Practices for Loading Data • How to handle time series, sorted data
  • 36. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Sensor data collection IoT rules IoT actions MQTT Amazon S3: Raw records Amazon Kinesis Firehose: Delivery stream Amazon S3: Batched records Amazon Kinesis Streams: Real-time stream AWS IoT: Data collection IoT Sensors Real-time analytics applications
  • 37. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Real-time analytics Amazon Kinesis Streams: Ingest stream Amazon Kinesis Analytics: Time window aggregation Amazon Kinesis Streams: Aggregates stream Amazon Kinesis Firehose: Error stream Amazon S3: Error records Record Producers AWS Lambda: Alert function Amazon DynamoDB: Device thresholds AWS SNS: Notifications
  • 38. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis Analytics CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM" SELECT STREAM "device_id", STEP("SOURCE_SQL_STREAM_001".ROWTIME BY INTERVAL '1' MINUTE) as "window_ts", SUM("measurement") as "sample_sum", COUNT(*) AS "sample_count" FROM "SOURCE_SQL_STREAM_001" GROUP BY "device_id", STEP("SOURCE_SQL_STREAM_001".ROWTIME BY INTERVAL '1' MINUTE); Aggregation 1-minute tumbling window Amazon Kinesis Analytics: Time window aggregation Source stream Destination stream
  • 39. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Real-time analytics Amazon Kinesis Streams: Ingest stream Amazon Kinesis Analytics: Time window aggregation Amazon Kinesis Streams: Aggregates stream Amazon Kinesis Firehose: Error stream Amazon S3: Error records Record Producers AWS Lambda: Alert function Amazon DynamoDB: Device thresholds AWS SNS: Notifications
  • 40. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Amazon Kinesis Streams and AWS Lambda • Number of Amazon Kinesis Streams shards corresponds to concurrent invocations of Lambda function • Batch size sets maximum number of records per Lambda function invocation Amazon Kinesis: Stream AWS Lambda: Processor function Streaming source Other AWS services
  • 41. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Fan-out pattern Fan-out pattern trades strict message ordering vs higher throughput & lower latency Amazon Kinesis: Stream Lambda: Dispatcher function Lambda: Processor function Increase throughput, reduce processing latency Streaming source
  • 42. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thomson Reuters – Product Insight Solution for usage analysis tracking: Capture, analyze, and visualize analytics data generated by offerings, providing insights to help product teams continuously improve the user experience Throughput: Tested 4,000 requests / second Growing to 10,000 requests / second or 25 Billion requests / month Latency: new events to user dashboards in less than 10 seconds Durable: no data loss since inception
  • 43. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best practices • Tune batch size when Lambda is triggered by Amazon Kinesis Streams • Higher batch size = fewer Lambda invocations • Tune memory setting for your Lambda function • Higher memory = shorter execution time • Use Kinesis Producer Library (KPL) to batch messages and saturate Amazon Kinesis Stream capacity
  • 44. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Pattern 4: Operations Automation
  • 45. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Automation characteristics • Periodic jobs • Event triggered workflows • Enforce security policies • Audit and notification • Respond to alarms • Extend AWS functionality … All while being Highly Available, Scalable and Auditable
  • 46. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Ops Automator Amazon CloudWatch: Time-based events AWS Lambda: Event handler AWS Lambda: Task executors AWS SNS: Error and warning notifications Resources in multiple AWS Regions and Accounts Amazon EC2 Instances Tags OpsAutomatorTaskList CreateSnapshotAmazon DynamoDB: Task configuration & tracking Amazon CloudWatch: Logs Amazon Redshift Clusters https://aws.amazon.com/answers/infrastructure-management/ops-automator/
  • 47. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Image recognition and processing Web App Amazon DynamoDB: Image meta-data & tags Amazon Cognito: User authentication Amazon S3: Image uploads AWS Step Functions: Workflow orchestration Start state machine execution 1 Extract image meta-data 2 Amazon Rekognition: Object detection Invoke Amazon Rekognition Generate image thumbnail 3 3Store meta-data and tags 4 https://github.com/awslabs/lambda-refarch-imagerecognition
  • 48. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Step Functions state machine
  • 49. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Enforce security policies RDP from 0.0.0.0/0 RDP from 0.0.0.0/0 CloudWatch Event Bus in another AWS Account New Security Group ingress rule Amazon CloudWatch Events: Rule AWS Lambda: Remediate and alert AWS SNS: Email alert Ingress rule deleted
  • 50. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Autodesk - Tailor Serverless AWS Account Provisioning and Management Service: • Automates AWS Account creation, • Configures IAM, CloudTrail, AWS Config, Direct Connect, and VPC • Enforces corporate standards • Audit for compliance Provisions new Accounts in 10 minutes vs 10 hours in earlier manual process Open source and extensible: https://github.com/alanwill/aws-tailor
  • 51. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Best practices • Gracefully handle API throttling by retrying with an exponential back-off algorithm (AWS SDKs do this for you) • Publish custom metrics from your Lambda function that are meaningful for operations (e.g. number of EBS volumes snapshotted) • Enable X-Ray tracing for your Lambda functions • Document how to disable event triggers for your automation when troubleshooting
  • 52. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Summary Use DevOps tools to automate your serverless deployments Apply serverless patterns for common use-cases: • Web application • Data Lake Foundation • Stream processing • Operations automation What will you build with Serverless?
  • 53. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved.© 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Further Reading • Optimizing Enterprise Economics with Serverless Architectures https://d0.awsstatic.com/whitepapers/optimizing-enterprise-economics-serverless-architectures.pdf • Serverless Architectures with AWS Lambda https://d1.awsstatic.com/whitepapers/serverless-architectures-with-aws-lambda.pdf • Serverless Applications Lens - AWS Well-Architected Framework https://d1.awsstatic.com/whitepapers/architecture/AWS-Serverless-Applications-Lens.pdf • Streaming Data Solutions on AWS with Amazon Kinesis https://d1.awsstatic.com/whitepapers/whitepaper-streaming-data-solutions-on-aws-with-amazon-kinesis.pdf • AWS Serverless Multi-Tier Architectures https://d1.awsstatic.com/whitepapers/AWS_Serverless_Multi-Tier_Archiectures.pdf
  • 54. © 2018, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank You! Pawan Puthran Snr. Technical Account Manager @pawanputhran