SlideShare a Scribd company logo
1 of 62
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Become a Serverless
Black Belt
Optimizing Your S er ver less Applications
A j a y N a i r , P r i n c i p a l P r o d u c t M a n a g e r , A W S S e r v e r l e s s A p p l i c a t i o n s
P e t e r S b a r s k i , V P , A C l o u d G u r u
S R V 4 0 1
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SERVERLESS CUSTOMERS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless is about maximizing elasticity,
cost savings, and agility.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MULTIPLE POINTS TO OPTIMIZE
Amazon
API
Gateway
Amazon
Alexa
AWS
IoT Amazon
Kinesis
Amazon
SNS
Amazon
SES
AWS Step
Functions 2
Invocations
1
Functions
3
Interactions
Amazon
S3
Amazon
DynamoDB
Custom
endpoints
Amazon
CloudWatch
Amazon
Elasticsearch
EC2
instance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
OPTIMIZATION KATAS
1. THE LEAN FUNCTION
2. EVENTFUL INVOCATIONS
3. COORDINATED CALLS
4. SERVICEFUL OPERATIONS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GOAL TODAY
Repeatable regimen for building highly
resilient, high-performance serverless
applications.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THE LEAN FUNCTION
K A T A # 1
Concise logic, efficient/single purpose code, ephemeral environment
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
ANATOMY OF A FUNCTION
Your
function
Language
runtime
Function
container
Compute
substrate
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THE REQUEST LIFECYCLE
Bootstrap
the runtime
Start your
code
Cold
start
Warm
start
Download
your code
Start new
container
AWS optimization Your optimization
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SAME VIEW IN X-RAY
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THE FUNCTION LIFECYCLE
Bootstrap
the runtime
Start your
code
Warm
start
Download
your code
Start new
container
AWS optimization Your optimization
Cold
start
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EFFICIENT FUNCTION CODE
• Avoid “fat”/monolithic functions
• Control the dependencies in your
function's deployment package
• Optimize for your language
• Node – Browserfy, Minify
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
JAVA – SCOPE YOUR POM FILE
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>2.10.10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.10.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-dynamodb</artifactId>
<version>1.10.10</version>
</dependency>
<dependencies>
Maven Bill Of Materials
(BOM) module for AWS
SDK
Avoid aws-java-sdk directly!
Select service
dependencies only
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EPHEMERAL FUNCTION ENVIRONMENT
• Lambda processes a single event
per-container
• No need for non-blocking execution
on the frontend
• REMEMBER – containers are reused
• Lazily load variables in the global
scope
• Don’t load it if you don’t need it –
cold starts are affected
import boto3
client = None
def my_handler(event, context):
global client
if not client:
client =
boto3.client("s3")
# process
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CONCISE FUNCTION LOGIC
• Separate Lambda handler (entry point) from
core logic
• Use functions to TRANSFORM, not TRANSPORT
• Read only what you need
• Query filters in Amazon Aurora
• Use Amazon S3 select (new!)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
200 seconds and 11.2 cents
# Download and process all keys
for key in src_keys:
response =
s3_client.get_object(Bucket=src_bucket,
Key=key)
contents = response['Body'].read()
for line in contents.split('n')[:-1]:
line_count +=1
try:
data = line.split(',')
srcIp = data[0][:8]
….
95 seconds and costs 2.8 cents
# Select IP Address and Keys
for key in src_keys:
response =
s3_client.select_object_content
(Bucket=src_bucket, Key=key,
expression =
SELECT SUBSTR(obj._1, 1, 8),
obj._2 FROM s3object as obj)
contents = response['Body'].read()
for line in contents:
line_count +=1
try:
….
A f t e rB e f o r e
SMALL CHANGES, BIG DIFFERENCE
(https://github.com/awslabs/lambda-refarch-mapreduce)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SMART RESOURCE ALLOCATION
Match resource allocation (up to 3 GB!) to logic
Stats for Lambda function that calculates 1000 times all prime
numbers <= 1000000
128 MB 11.722965sec $0.024628
256 MB 6.678945sec $0.028035
512 MB 3.194954sec $0.026830
1024 MB 1.465984sec $0.024638
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
IMPACT OF MEMORY CHANGE
50% increase
in memory
95th percentile
changes from
3s to 2.1s
https://blog.newrelic.com/2017/06/20/lambda-functions-xray-traces-
custom-serverless-metrics/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DON’T GUESSTIMATE!
alexcasalboni
aws-lambda-power-tuning
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MULTITHREADING? MAYBE
• <1.8GB is still single core
• CPU bound workloads won’t see gains – processes share
same resources
• >1.8GB is muti-core
• CPU bound workloads will gains, but need to multi thread
• I/O bound workloads WILL likely see gains
• e.g. parallel calculations to return
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
NO ORCHESTRATION IN CODESTARTJOB
JOB#XSTARTED
HTTPPOST
HTTPPOST
AREWETHEREYET?
NOPE!
WE’REDONE!
ZzZz
OR
time.sleep(10)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
NO ORCHESTRATION IN CODE
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THE LEAN FUNCTION
K A T A # 1
Concise logic, efficient/single purpose code, ephemeral environment
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EVENTFUL INVOCATIONS
K A T A # 2
Succinct payloads, resilient routing, concurrent execution
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INVOCATION PATHS
Amazon
API
Gateway
Amazon
Alexa
AWS
IoT Amazon
Kinesis
Amazon
SNS
Amazon
SES
AWS Step
Functions
Amazon
S3
Amazon
DynamoDB
Custom
endpoints
Amazon
CloudWatch
Amazon
Elasticsearch
EC2
instance
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
GATEWAYS AND ROUTERS
• Choose suitable entry point for client
applications
• Single, custom client? Use the
AWS SDK
• Not end user facing? use regional
endpoints on API Gateway
• Discard uninteresting events ASAP
• S3 – Event prefix
• SNS – Message filtering (new!)
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
• Scrutinize the event
• Must have provenance i.e. “What happened for this notification
to occur?”
• Additional content – identifier or payload
• Remember payload constraints
• Async invocation is only 128K
• Avoid large responses like an image
SUCCINT INVOCATIONS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EXAMPLE - SWITCH TO BINARY
'use strict';
const co = require('co');
const Promise = require('bluebird');
const protobuf = Promise.prmisifyAll(require("protobufjs"));
const lib = require('./lib');
const fs = require('fs');
module.exports.handler = co.wrap(function* (event, context, callback) {
console.log(JSON.stringify(event));
let players = lib.genPlayers();
let root = yield protobuf.loadAsync("functions/player.proto");
let Players = root.lookupType("protodemo.Players");
let message = Players.create(players);
let buffer = Players.encode(message).finish();
const response = {
statusCode: 200,
headers: { 'Content-Type': 'application/x-protobuf' },
body: buffer.toString('base64'),
isBase64Encoded: true
};
http://theburningmonk.com/2017/09/using-protocol-buffers-with-api-
gateway-and-aws-lambda/
The same response in
Protocol Buffers
is nearly 40% smaller
compared to default
JSON
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
VS.
RESILIENT: USE AN EVENT STORE
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
CONCURRENCY vs LATENCY
Streams
• Maximum theoretical throughput:
# shards * 2 MB / (s)
• Effective theoretical throughput:
( # shards * batch size (MB) ) /
( function duration (s) * retries
until expiry)
• If put / ingestion rate is greater than
the theoretical throughput, consider
increasing number of shards while
optimizing function duration to
increase throughput
Everything else
• Maximum Processing rate :
Maximum concurrency / average
duration (events per second)
• Effective Processing rate :
Effective concurrency / average
duration (events per second)
• Use concurrency metric (new!) and
duration metric to estimate processing
time
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THINK CONCURRENT, NOT TPS
Queue based
Simple
No event store
Stream based
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
RESILENT: RETRY POLICIES
• Understand retry policies
• Sync never retried
• Async retried 2 times
• Streams retried all the time
• Leverage Dead Letter Queues
• SQS or SNS for replays
• REMEMBER: Retries count as invokes
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
BUILD YOUR OWN
http://theburningmonk.com/2017/04/aws-lambda-3-pro-tips-for-working-with-kinesis-streams/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
EVENTFUL INVOCATIONS
K A T A # 2
Succinct payloads, resilient routing, concurrent execution
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
COORDINATED CALLS
K A T A # 3
Decoupled via APIs, scale-matched downstream, secured
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
DECOUPLED: APIs AS CONTRACTS
Ingestion service
Ingestion
API
ingest
&
sanitize()
Metadata service
CRUD
API
read & write
metadata()
Frontend service
Frontend
API
express()
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SCALE-MATCHED: CONCURRENCY CONTROLS
• Concurrency a shared pool by default
• Separate using per function concurrency settings
• Acts as reservation
• Also acts as max concurrency per function
• Especially critical for data sources like RDS
• “Kill switch” – set per function concurrency to zero
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SECURED: DO I NEED A VPC?
Should my
Lambda
function be
in a VPC?
Does my function
need to access
any specific
resources in a
VPC?
Does it also need to
access resources or
services in the
public internet?
Don’t put the
function in a
VPC
Put the
function in a
private subnet
Put the
function in a
subnet with a
NAT’d route to
the internet
Yes Yes
No No
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Download
your code
Start new
container
Create
VPC ENI
Start your
code
Attach
VPC ENI
Full
cold start
Warm
start
Bootstrap
runtime
AWS optimization Your optimization
SECURED: VPC vs LATENCY
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SECURED: VPC vs RESILIENCE
• ALWAYS configure a minimum of 2 Availability Zones
• Give your Lambda functions their own subnets
• Give your Lambda subnets a large IP range to handle
potential scale
• If your functions need to talk to a resource on the
internet, you need a NAT!
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
COORDINATED CALLS
K A T A # 3
Decoupled via APIs, scale-matched downstream, secured
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SERVICEFUL OPERATIONS
K A T A # 4
Automated operations, Monitored applications, Innovation mindset
In the end, it’s about the people
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A CLOUD GURU: SERVERLESS COMPANY
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
WEEKLY STATS
6.21M Lambda
Invocations
~ 4M API Requests
480 Lambda Functions
15 Environments
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
2+ TB of data in S3
7+ TB of data served weekly via CloudFront
WEEKLY STATS
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AUTOMATE
MONITOR
INNOVATE
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AUTOMATION AT ACG
ANSIBLE
Other Services
Frontend
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AUTOMATION AT ACG: TESTING
Selenium Jester
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AUTOMATE
MONITOR
INNOVATE
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MONITORING - ALERTS
566 CloudWatch alarmsDashboards covering services we use
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MONITORING - DASHBOARDS
Runscope Monitoring
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MONITORING - SECURITY
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AUTOMATE
MIGRATE
INNOVATE
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INCREMENTAL ARCHITECTURE
Serverless
Monolith
Serverless
Microservices
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INNOVATION
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
INNOVATION
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
A FEW PUBLIC PROJECTS FROM ACG
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Serverless is a mindset change toward
automation, agility, and innovation.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
SERVICEFUL OPERATIONS
K A T A # 4
Automated operations, Monitored applications, Innovation mindset
In the end, it’s about the people
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
OPTIMIZATION KATAS
1. THE LEAN FUNCTION
CONCISE. EFFICIENT. EPHEMERAL.
2. EVENTFUL INVOCATIONS
SUCCINT. RESILIENT. CONCURRENT.
3. COORDINATED CALLS
DECOUPLED. SCALE MATCHED.
SECURED.
4. SERVICEFUL OPERATIONS
AUTOMATE. MONITOR. INNOVATE.
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
MORE OPTIMIZATION SESSIONS
SRV303 - Monitoring and Troubleshooting in a Serverless World
SRV322-R2 - Migration to Serverless: Design Patterns and Best Practices
SRV311 - Authoring and Deploying Serverless Applications with AWS SAM
SRV320-R - Best Practices for Using AWS Lambda with RDS/RDBMS
Solutions
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
THANK YOU!

More Related Content

What's hot

CMP314_Bringing Deep Learning to the Cloud with Amazon EC2
CMP314_Bringing Deep Learning to the Cloud with Amazon EC2CMP314_Bringing Deep Learning to the Cloud with Amazon EC2
CMP314_Bringing Deep Learning to the Cloud with Amazon EC2Amazon Web Services
 
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017Amazon Web Services
 
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveGPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveAmazon Web Services
 
Podcasting on AWS – A Discussion on Everything from Production to Distributio...
Podcasting on AWS – A Discussion on Everything from Production to Distributio...Podcasting on AWS – A Discussion on Everything from Production to Distributio...
Podcasting on AWS – A Discussion on Everything from Production to Distributio...Amazon Web Services
 
MCL308_Using a Digital Assistant in the Enterprise for Business Productivity
MCL308_Using a Digital Assistant in the Enterprise for Business ProductivityMCL308_Using a Digital Assistant in the Enterprise for Business Productivity
MCL308_Using a Digital Assistant in the Enterprise for Business ProductivityAmazon Web Services
 
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...Amazon Web Services
 
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017Amazon Web Services
 
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017Amazon Web Services
 
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...Amazon Web Services
 
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...Amazon Web Services
 
WPS205_Is AWS GovCloud Right for your Regulated Workload
WPS205_Is AWS GovCloud Right for your Regulated WorkloadWPS205_Is AWS GovCloud Right for your Regulated Workload
WPS205_Is AWS GovCloud Right for your Regulated WorkloadAmazon Web Services
 
SID302_Force Multiply Your Security Team with Automation and Alexa
SID302_Force Multiply Your Security Team with Automation and AlexaSID302_Force Multiply Your Security Team with Automation and Alexa
SID302_Force Multiply Your Security Team with Automation and AlexaAmazon Web Services
 
ALX401-Advanced Alexa Skill Building Conversation and Memory
ALX401-Advanced Alexa Skill Building Conversation and MemoryALX401-Advanced Alexa Skill Building Conversation and Memory
ALX401-Advanced Alexa Skill Building Conversation and MemoryAmazon Web Services
 
GPSTEC302_Anti-Patterns- Learning through Failure
GPSTEC302_Anti-Patterns- Learning through FailureGPSTEC302_Anti-Patterns- Learning through Failure
GPSTEC302_Anti-Patterns- Learning through FailureAmazon Web Services
 
GAM309-Breathe Life into a Mobile Game_NoNotes.pdf
GAM309-Breathe Life into a Mobile Game_NoNotes.pdfGAM309-Breathe Life into a Mobile Game_NoNotes.pdf
GAM309-Breathe Life into a Mobile Game_NoNotes.pdfAmazon Web Services
 
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...Amazon Web Services
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural PatternsAdrian Hornsby
 
FSV305-Optimizing Payments Collections with Containers and Machine Learning
FSV305-Optimizing Payments Collections with Containers and Machine LearningFSV305-Optimizing Payments Collections with Containers and Machine Learning
FSV305-Optimizing Payments Collections with Containers and Machine LearningAmazon Web Services
 
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017Amazon Web Services
 
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdf
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdfSRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdf
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdfAmazon Web Services
 

What's hot (20)

CMP314_Bringing Deep Learning to the Cloud with Amazon EC2
CMP314_Bringing Deep Learning to the Cloud with Amazon EC2CMP314_Bringing Deep Learning to the Cloud with Amazon EC2
CMP314_Bringing Deep Learning to the Cloud with Amazon EC2
 
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017
NEW LAUNCH! Deep dive on Amazon Neptune - DAT318 - re:Invent 2017
 
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to MoveGPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
GPSTEC314-GPS From Monolithic to Serverless - Why and How to Move
 
Podcasting on AWS – A Discussion on Everything from Production to Distributio...
Podcasting on AWS – A Discussion on Everything from Production to Distributio...Podcasting on AWS – A Discussion on Everything from Production to Distributio...
Podcasting on AWS – A Discussion on Everything from Production to Distributio...
 
MCL308_Using a Digital Assistant in the Enterprise for Business Productivity
MCL308_Using a Digital Assistant in the Enterprise for Business ProductivityMCL308_Using a Digital Assistant in the Enterprise for Business Productivity
MCL308_Using a Digital Assistant in the Enterprise for Business Productivity
 
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...
Building the Largest Repo for Serverless Compliance-as-Code - SID205 - re:Inv...
 
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
Introducing Service Discovery for Amazon ECS - CON403 - re:Invent 2017
 
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
Oracle Enterprise Solutions on AWS - ENT326 - re:Invent 2017
 
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...
GPSTEC309-SaaS Monitoring Creating a Unified View of Multitenant Health featu...
 
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...
NEW LAUNCH! Building Virtual Reality and Augmented Reality Applications with ...
 
WPS205_Is AWS GovCloud Right for your Regulated Workload
WPS205_Is AWS GovCloud Right for your Regulated WorkloadWPS205_Is AWS GovCloud Right for your Regulated Workload
WPS205_Is AWS GovCloud Right for your Regulated Workload
 
SID302_Force Multiply Your Security Team with Automation and Alexa
SID302_Force Multiply Your Security Team with Automation and AlexaSID302_Force Multiply Your Security Team with Automation and Alexa
SID302_Force Multiply Your Security Team with Automation and Alexa
 
ALX401-Advanced Alexa Skill Building Conversation and Memory
ALX401-Advanced Alexa Skill Building Conversation and MemoryALX401-Advanced Alexa Skill Building Conversation and Memory
ALX401-Advanced Alexa Skill Building Conversation and Memory
 
GPSTEC302_Anti-Patterns- Learning through Failure
GPSTEC302_Anti-Patterns- Learning through FailureGPSTEC302_Anti-Patterns- Learning through Failure
GPSTEC302_Anti-Patterns- Learning through Failure
 
GAM309-Breathe Life into a Mobile Game_NoNotes.pdf
GAM309-Breathe Life into a Mobile Game_NoNotes.pdfGAM309-Breathe Life into a Mobile Game_NoNotes.pdf
GAM309-Breathe Life into a Mobile Game_NoNotes.pdf
 
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...
NEW LAUNCH! Amazon Rekognition Video eliminates manual cataloging of video wh...
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
FSV305-Optimizing Payments Collections with Containers and Machine Learning
FSV305-Optimizing Payments Collections with Containers and Machine LearningFSV305-Optimizing Payments Collections with Containers and Machine Learning
FSV305-Optimizing Payments Collections with Containers and Machine Learning
 
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017
Integrating Video in Mobile Apps and Websites - MBL308 - re:Invent 2017
 
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdf
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdfSRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdf
SRV332_Building Serverless Real-Time Data Processing (Now with Unicorns!).pdf
 

Similar to Become a Serverless Black Belt: Optimizing Your Serverless Applications - SRV401 - re:Invent 2017

AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAmazon Web Services
 
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017High-Throughput Genomics on AWS - LFS309 - re:Invent 2017
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017Amazon Web Services
 
LFS309-High-Throughput Genomics on AWS.pdf
LFS309-High-Throughput Genomics on AWS.pdfLFS309-High-Throughput Genomics on AWS.pdf
LFS309-High-Throughput Genomics on AWS.pdfAmazon Web Services
 
Building .NET-based Serverless Architectures and Running .NET Core Microservi...
Building .NET-based Serverless Architectures and Running .NET Core Microservi...Building .NET-based Serverless Architectures and Running .NET Core Microservi...
Building .NET-based Serverless Architectures and Running .NET Core Microservi...Amazon Web Services
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersAmazon Web Services
 
CON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSCON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSAmazon Web Services
 
SRV312_Taking Serverless to the Edge
SRV312_Taking Serverless to the EdgeSRV312_Taking Serverless to the Edge
SRV312_Taking Serverless to the EdgeAmazon Web Services
 
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaScale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaAmazon Web Services
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural PatternsAmazon Web Services
 
Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Amazon Web Services
 
Genomics on aws-webinar-april2018
Genomics on aws-webinar-april2018Genomics on aws-webinar-april2018
Genomics on aws-webinar-april2018Brendan Bouffler
 
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...Amazon Web Services
 
透過Spot instances, Containers & Serverless降低成本
透過Spot instances, Containers & Serverless降低成本透過Spot instances, Containers & Serverless降低成本
透過Spot instances, Containers & Serverless降低成本Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Amazon Web Services
 
Use Amazon Rekognition to Build a Facial Recognition System
Use Amazon Rekognition to Build a Facial Recognition SystemUse Amazon Rekognition to Build a Facial Recognition System
Use Amazon Rekognition to Build a Facial Recognition SystemAmazon Web Services
 

Similar to Become a Serverless Black Belt: Optimizing Your Serverless Applications - SRV401 - re:Invent 2017 (20)

Serverless Architectures.pdf
Serverless Architectures.pdfServerless Architectures.pdf
Serverless Architectures.pdf
 
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech TalksAWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
AWS X-Ray: Debugging Applications at Scale - AWS Online Tech Talks
 
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017High-Throughput Genomics on AWS - LFS309 - re:Invent 2017
High-Throughput Genomics on AWS - LFS309 - re:Invent 2017
 
LFS309-High-Throughput Genomics on AWS.pdf
LFS309-High-Throughput Genomics on AWS.pdfLFS309-High-Throughput Genomics on AWS.pdf
LFS309-High-Throughput Genomics on AWS.pdf
 
Building .NET-based Serverless Architectures and Running .NET Core Microservi...
Building .NET-based Serverless Architectures and Running .NET Core Microservi...Building .NET-based Serverless Architectures and Running .NET Core Microservi...
Building .NET-based Serverless Architectures and Running .NET Core Microservi...
 
ARC205_Born in the Cloud
ARC205_Born in the CloudARC205_Born in the Cloud
ARC205_Born in the Cloud
 
Scaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million UsersScaling Up to Your First 10 Million Users
Scaling Up to Your First 10 Million Users
 
CON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWSCON309_Containerized Machine Learning on AWS
CON309_Containerized Machine Learning on AWS
 
SRV312_Taking Serverless to the Edge
SRV312_Taking Serverless to the EdgeSRV312_Taking Serverless to the Edge
SRV312_Taking Serverless to the Edge
 
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta penggunaScale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
Scale Website dan Mobile Applications Anda di AWS hingga 10 juta pengguna
 
Serverless Developer Experience
Serverless Developer ExperienceServerless Developer Experience
Serverless Developer Experience
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
Building Web Apps on AWS
Building Web Apps on AWSBuilding Web Apps on AWS
Building Web Apps on AWS
 
Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...Learn how to build serverless applications using the AWS Serverless Platform-...
Learn how to build serverless applications using the AWS Serverless Platform-...
 
Genomics on aws-webinar-april2018
Genomics on aws-webinar-april2018Genomics on aws-webinar-april2018
Genomics on aws-webinar-april2018
 
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
SRV331_Build a Multi-Region Serverless Application for Resilience and High Av...
 
透過Spot instances, Containers & Serverless降低成本
透過Spot instances, Containers & Serverless降低成本透過Spot instances, Containers & Serverless降低成本
透過Spot instances, Containers & Serverless降低成本
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
Building Serverless Websites with Lambda@Edge - CTD309 - re:Invent 2017
 
Use Amazon Rekognition to Build a Facial Recognition System
Use Amazon Rekognition to Build a Facial Recognition SystemUse Amazon Rekognition to Build a Facial Recognition System
Use Amazon Rekognition to Build a Facial Recognition System
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS 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
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
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
 

Become a Serverless Black Belt: Optimizing Your Serverless Applications - SRV401 - re:Invent 2017

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Become a Serverless Black Belt Optimizing Your S er ver less Applications A j a y N a i r , P r i n c i p a l P r o d u c t M a n a g e r , A W S S e r v e r l e s s A p p l i c a t i o n s P e t e r S b a r s k i , V P , A C l o u d G u r u S R V 4 0 1
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SERVERLESS CUSTOMERS
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless is about maximizing elasticity, cost savings, and agility.
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MULTIPLE POINTS TO OPTIMIZE Amazon API Gateway Amazon Alexa AWS IoT Amazon Kinesis Amazon SNS Amazon SES AWS Step Functions 2 Invocations 1 Functions 3 Interactions Amazon S3 Amazon DynamoDB Custom endpoints Amazon CloudWatch Amazon Elasticsearch EC2 instance
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. OPTIMIZATION KATAS 1. THE LEAN FUNCTION 2. EVENTFUL INVOCATIONS 3. COORDINATED CALLS 4. SERVICEFUL OPERATIONS
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GOAL TODAY Repeatable regimen for building highly resilient, high-performance serverless applications.
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THE LEAN FUNCTION K A T A # 1 Concise logic, efficient/single purpose code, ephemeral environment
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. ANATOMY OF A FUNCTION Your function Language runtime Function container Compute substrate
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THE REQUEST LIFECYCLE Bootstrap the runtime Start your code Cold start Warm start Download your code Start new container AWS optimization Your optimization
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SAME VIEW IN X-RAY
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THE FUNCTION LIFECYCLE Bootstrap the runtime Start your code Warm start Download your code Start new container AWS optimization Your optimization Cold start
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EFFICIENT FUNCTION CODE • Avoid “fat”/monolithic functions • Control the dependencies in your function's deployment package • Optimize for your language • Node – Browserfy, Minify
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. JAVA – SCOPE YOUR POM FILE <dependencyManagement> <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-bom</artifactId> <version>2.10.10</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-s3</artifactId> <version>1.10.5</version> </dependency> <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-dynamodb</artifactId> <version>1.10.10</version> </dependency> <dependencies> Maven Bill Of Materials (BOM) module for AWS SDK Avoid aws-java-sdk directly! Select service dependencies only
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EPHEMERAL FUNCTION ENVIRONMENT • Lambda processes a single event per-container • No need for non-blocking execution on the frontend • REMEMBER – containers are reused • Lazily load variables in the global scope • Don’t load it if you don’t need it – cold starts are affected import boto3 client = None def my_handler(event, context): global client if not client: client = boto3.client("s3") # process
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CONCISE FUNCTION LOGIC • Separate Lambda handler (entry point) from core logic • Use functions to TRANSFORM, not TRANSPORT • Read only what you need • Query filters in Amazon Aurora • Use Amazon S3 select (new!)
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 200 seconds and 11.2 cents # Download and process all keys for key in src_keys: response = s3_client.get_object(Bucket=src_bucket, Key=key) contents = response['Body'].read() for line in contents.split('n')[:-1]: line_count +=1 try: data = line.split(',') srcIp = data[0][:8] …. 95 seconds and costs 2.8 cents # Select IP Address and Keys for key in src_keys: response = s3_client.select_object_content (Bucket=src_bucket, Key=key, expression = SELECT SUBSTR(obj._1, 1, 8), obj._2 FROM s3object as obj) contents = response['Body'].read() for line in contents: line_count +=1 try: …. A f t e rB e f o r e SMALL CHANGES, BIG DIFFERENCE (https://github.com/awslabs/lambda-refarch-mapreduce)
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SMART RESOURCE ALLOCATION Match resource allocation (up to 3 GB!) to logic Stats for Lambda function that calculates 1000 times all prime numbers <= 1000000 128 MB 11.722965sec $0.024628 256 MB 6.678945sec $0.028035 512 MB 3.194954sec $0.026830 1024 MB 1.465984sec $0.024638
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. IMPACT OF MEMORY CHANGE 50% increase in memory 95th percentile changes from 3s to 2.1s https://blog.newrelic.com/2017/06/20/lambda-functions-xray-traces- custom-serverless-metrics/
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DON’T GUESSTIMATE! alexcasalboni aws-lambda-power-tuning
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MULTITHREADING? MAYBE • <1.8GB is still single core • CPU bound workloads won’t see gains – processes share same resources • >1.8GB is muti-core • CPU bound workloads will gains, but need to multi thread • I/O bound workloads WILL likely see gains • e.g. parallel calculations to return
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. NO ORCHESTRATION IN CODESTARTJOB JOB#XSTARTED HTTPPOST HTTPPOST AREWETHEREYET? NOPE! WE’REDONE! ZzZz OR time.sleep(10)
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. NO ORCHESTRATION IN CODE
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THE LEAN FUNCTION K A T A # 1 Concise logic, efficient/single purpose code, ephemeral environment
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EVENTFUL INVOCATIONS K A T A # 2 Succinct payloads, resilient routing, concurrent execution
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. INVOCATION PATHS Amazon API Gateway Amazon Alexa AWS IoT Amazon Kinesis Amazon SNS Amazon SES AWS Step Functions Amazon S3 Amazon DynamoDB Custom endpoints Amazon CloudWatch Amazon Elasticsearch EC2 instance
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. GATEWAYS AND ROUTERS • Choose suitable entry point for client applications • Single, custom client? Use the AWS SDK • Not end user facing? use regional endpoints on API Gateway • Discard uninteresting events ASAP • S3 – Event prefix • SNS – Message filtering (new!)
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. • Scrutinize the event • Must have provenance i.e. “What happened for this notification to occur?” • Additional content – identifier or payload • Remember payload constraints • Async invocation is only 128K • Avoid large responses like an image SUCCINT INVOCATIONS
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EXAMPLE - SWITCH TO BINARY 'use strict'; const co = require('co'); const Promise = require('bluebird'); const protobuf = Promise.prmisifyAll(require("protobufjs")); const lib = require('./lib'); const fs = require('fs'); module.exports.handler = co.wrap(function* (event, context, callback) { console.log(JSON.stringify(event)); let players = lib.genPlayers(); let root = yield protobuf.loadAsync("functions/player.proto"); let Players = root.lookupType("protodemo.Players"); let message = Players.create(players); let buffer = Players.encode(message).finish(); const response = { statusCode: 200, headers: { 'Content-Type': 'application/x-protobuf' }, body: buffer.toString('base64'), isBase64Encoded: true }; http://theburningmonk.com/2017/09/using-protocol-buffers-with-api- gateway-and-aws-lambda/ The same response in Protocol Buffers is nearly 40% smaller compared to default JSON
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. VS. RESILIENT: USE AN EVENT STORE
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. CONCURRENCY vs LATENCY Streams • Maximum theoretical throughput: # shards * 2 MB / (s) • Effective theoretical throughput: ( # shards * batch size (MB) ) / ( function duration (s) * retries until expiry) • If put / ingestion rate is greater than the theoretical throughput, consider increasing number of shards while optimizing function duration to increase throughput Everything else • Maximum Processing rate : Maximum concurrency / average duration (events per second) • Effective Processing rate : Effective concurrency / average duration (events per second) • Use concurrency metric (new!) and duration metric to estimate processing time
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THINK CONCURRENT, NOT TPS Queue based Simple No event store Stream based
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. RESILENT: RETRY POLICIES • Understand retry policies • Sync never retried • Async retried 2 times • Streams retried all the time • Leverage Dead Letter Queues • SQS or SNS for replays • REMEMBER: Retries count as invokes
  • 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. BUILD YOUR OWN http://theburningmonk.com/2017/04/aws-lambda-3-pro-tips-for-working-with-kinesis-streams/
  • 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. EVENTFUL INVOCATIONS K A T A # 2 Succinct payloads, resilient routing, concurrent execution
  • 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. COORDINATED CALLS K A T A # 3 Decoupled via APIs, scale-matched downstream, secured
  • 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. DECOUPLED: APIs AS CONTRACTS Ingestion service Ingestion API ingest & sanitize() Metadata service CRUD API read & write metadata() Frontend service Frontend API express()
  • 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SCALE-MATCHED: CONCURRENCY CONTROLS • Concurrency a shared pool by default • Separate using per function concurrency settings • Acts as reservation • Also acts as max concurrency per function • Especially critical for data sources like RDS • “Kill switch” – set per function concurrency to zero
  • 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SECURED: DO I NEED A VPC? Should my Lambda function be in a VPC? Does my function need to access any specific resources in a VPC? Does it also need to access resources or services in the public internet? Don’t put the function in a VPC Put the function in a private subnet Put the function in a subnet with a NAT’d route to the internet Yes Yes No No
  • 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Download your code Start new container Create VPC ENI Start your code Attach VPC ENI Full cold start Warm start Bootstrap runtime AWS optimization Your optimization SECURED: VPC vs LATENCY
  • 40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SECURED: VPC vs RESILIENCE • ALWAYS configure a minimum of 2 Availability Zones • Give your Lambda functions their own subnets • Give your Lambda subnets a large IP range to handle potential scale • If your functions need to talk to a resource on the internet, you need a NAT!
  • 41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. COORDINATED CALLS K A T A # 3 Decoupled via APIs, scale-matched downstream, secured
  • 42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SERVICEFUL OPERATIONS K A T A # 4 Automated operations, Monitored applications, Innovation mindset In the end, it’s about the people
  • 43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A CLOUD GURU: SERVERLESS COMPANY
  • 44. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. WEEKLY STATS 6.21M Lambda Invocations ~ 4M API Requests 480 Lambda Functions 15 Environments
  • 45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. 2+ TB of data in S3 7+ TB of data served weekly via CloudFront WEEKLY STATS
  • 46. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AUTOMATE MONITOR INNOVATE
  • 47. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AUTOMATION AT ACG ANSIBLE Other Services Frontend
  • 48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AUTOMATION AT ACG: TESTING Selenium Jester
  • 49. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AUTOMATE MONITOR INNOVATE
  • 50. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MONITORING - ALERTS 566 CloudWatch alarmsDashboards covering services we use
  • 51. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MONITORING - DASHBOARDS Runscope Monitoring
  • 52. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MONITORING - SECURITY
  • 53. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AUTOMATE MIGRATE INNOVATE
  • 54. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. INCREMENTAL ARCHITECTURE Serverless Monolith Serverless Microservices
  • 55. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. INNOVATION
  • 56. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. INNOVATION
  • 57. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. A FEW PUBLIC PROJECTS FROM ACG
  • 58. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Serverless is a mindset change toward automation, agility, and innovation.
  • 59. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. SERVICEFUL OPERATIONS K A T A # 4 Automated operations, Monitored applications, Innovation mindset In the end, it’s about the people
  • 60. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. OPTIMIZATION KATAS 1. THE LEAN FUNCTION CONCISE. EFFICIENT. EPHEMERAL. 2. EVENTFUL INVOCATIONS SUCCINT. RESILIENT. CONCURRENT. 3. COORDINATED CALLS DECOUPLED. SCALE MATCHED. SECURED. 4. SERVICEFUL OPERATIONS AUTOMATE. MONITOR. INNOVATE.
  • 61. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. MORE OPTIMIZATION SESSIONS SRV303 - Monitoring and Troubleshooting in a Serverless World SRV322-R2 - Migration to Serverless: Design Patterns and Best Practices SRV311 - Authoring and Deploying Serverless Applications with AWS SAM SRV320-R - Best Practices for Using AWS Lambda with RDS/RDBMS Solutions
  • 62. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. THANK YOU!