SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS re:INVENTHow We Built a Mission-Critical,
Serverless File Processing Pipeline
for over 100 Million Photos
M i k e B r o a d w a y , P r i n c i p a l A r c h i t e c t , H o m e A w a y
N o v e m b e r 2 7 , 2 0 1 7
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
About Me —Mik e Br oadw ay
A recovering start-up junkie
Designing and writing software for ~40 years
• Mainframe device drivers, word processors, terminal
emulators, financial planners, job schedulers, etc.
A Principal Architect at HomeAway, Expedia
• Focus on content, media, identity, communications, etc.
• Anything that is not UX or payment-related
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
W hat I W ill Talk About
• Why we needed a new photo storage system
• How we met that need with AWS Serverless
• Amazon Simple Storage Service (S3), AWS
Lambdas, Amazon DynamoDB, Amazon
Kinesis, etc.
• The best practices that we learned
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Shor t Shelf Life War ning
AWS is iterating rapidly …
… this talk will be out of date soon
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
H omeAw ay– A Vac ation R ental Mar k etplac e
2 million places to stay
in 190 countries
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
H omeAw ay H as a Lot of Photos !
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
H ow Many Photos ?
• ~ 6 million original image uploads/month
• ~ 5 terabytes/month
• ~ 80 million unique originals
• ~ 1.5 billion “treatment” derivatives
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
H ow D id H omeAw ay Manage Images Befor e?
• A farm of Java application servers in Austin
• Implemented nine years ago
• Design goals defined for acquired brands
• Network Attached Storage/NFS
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Pr evious Image Sys tem —Expens ive & D ated
Pricey top tier network storage …
$5,000/terabyte
$20,000 to $25,000/month
Hard-coded treatment sizes
4x3 aspect ratio
1024 largest width
then now
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
H ighly Var iable U pload Volume
Image uploads/hour over one week
Nine image uploads per second
@ 12:03 p.m. Saturday
Even the smaller peaks are a
doubling and tripling of traffic
225:1 Load Ratio
25 seconds between image uploads
@ 00:40 a.m. Monday
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
We U pgr aded to an AW S Ser ver les s Solution
• AWS Lambda for extreme scalability
• Amazon S3 to address the storage costs
• DynamoDB for metadata and treatment definitions
• Multi-region for high availability
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
A Ver y Shor t Intr oduc tion to AW S Lambda
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
• Single function code blocks
• No threads to manage
• No server patches to apply
• Fine-grained scaling
• Only runs when triggered
• Only pay for what runs
AW S Lambda Over view
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
'use strict';
exports.lambda_handler = function(event, context, callback) {
var message = event.Records[0].Sns.Message;
console.log('Message received from SNS:', message);
callback(null, "Success");
};
Tr ivial J avaSc r ipt Example
… logs the content of an SNS message
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
@Override
public Response handleRequest(SNSEvent event, Context context) {
return handleSNSEvent(event, context, Disposition.class, disposition -> {
if (disposition.getStatusFlag().equals(Disposition.Status.DEPRECATED)) {
... logging ...
return;
}
if (isBlacklistedPhoto(disposition)) {
throw new ErrorResponseException(... description ...);
}
... logging ...
BucketDescriptor sourceBucketDescriptor =
new BucketDescriptor(getBusinessDescriptor(), getEnvironmentDescriptor(), BucketDescriptor.Type.MASTER);
ImageFileDescriptor sourceImageFileDescriptor =
new ImageFileDescriptor(sourceBucketDescriptor, disposition.getS3Key());
getTreatmentProcessor().renderTreatmentSets(sourceImageFileDescriptor, disposition);
});
}
An Image Manipulation Lambda
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
OD IS: On D emand Image Ser vic e
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
The OD IS Image Pipeline
6000 x 4000
Original
2880 x 1920
Master
Client ready
“treatments”
Induction
λ
Treatment
caching
λ
S3 S3 S3
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Thr ee S3 Buc k ets — Thr ee Stages
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Adding Or iginal Images
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
D er iving the “ Mas ter ”
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
R ec or ding The Initial “ D is pos ition”
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
R eac ting to a N ew Image D is pos ition
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Pr e - C a c h in g Se le c te d Ima g e Tr e a tme n ts
NOTE: named “treatment definitions” are stored
in a second DynamoDB table (not shown)
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Ser ving Images to the C D N
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
R es ponding to C ac he Mis s es
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Alter ing an Image D is pos ition
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Keeping the C lient Platfor m Infor med
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Analyz ing Image C ontent and Quality
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Benefits of AW S Ser ver les s for OD IS
• Ultra fine-grained scalability
• Event-driven
• Rapid development
• Naturally flexible/extensible design
• Significant cost savings
• ~$5,000/month as opposed to > $25,000/month
• Simplified operations
• No patching, no server monitoring, etc.
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Bes t Pr ac tic es Lear ned
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Lambdas Ar e Als o Good for Sc heduled Tas k s
• Can schedule Lambdas to run at intervals or time
• At specified rate: rate(1 hour)
• At specified time: cron(0 17 ? * MON-FRI *)
• No need to have a server just to schedule a job
• Startup cost is irrelevant for such one-offs
• Not so much for long running jobs
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Amaz on API Gatew ay
API Gateway interfaces are always public
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Mor e C an Be Les s
• Initially, we minimized Lambda memory
• Lower memory = lower cost per 100ms
• But CPU is allocated proportionally
• Twice the memory = twice the CPU
• We saved money by configuring more memory!
• More memory = more CPU = shorter duration
• Optimize by experimentation
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Lambda Spin - U p & R eus e
Duration of the main, image processing, ODIS Lambdas
• Average: ~2.5 seconds
• First invocation: 10 to 12 seconds (GraphicsMagick, etc., setup)
Spiky traffic patterns may not allow start up costs to be amortized
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Only Inc lude W hat You N eed!
• Lambda jar/zip files must be less than 50 MB
• Java dependencies can add up!
• Use the Maven Shade or Gradle Shadow plugin
Maven Shade
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
One Pr ojec t to R ule Them All
• Keep it all together
• A single github project
• A single jar file/single deployment package
• Greatly simplifies management
• Simpler testing and version control
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
D eletion & Amaz on S3 Ver s ioning
82 million master images
Ramp up during migration from Austin data center
193 million original images???
Duh! Deletes are soft when S3
versioning is enabled
Master bucket
object count
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Lambda Thr ottling
• Account-wide limit on concurrent Lambdas
• Limit is per region, can be different across regions
• Now defaults to 1,000 (can request more)
• HomeAway currently at 1,500
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Worse: it could be another product and
another team in the same account
A surge here …
… starvation there
Lambda Thr ottling Pain
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
D ynamoD B Str eam H andling
Stream processing can be a bottleneck
• Minimize per event processing times
• Fan out to other, asynchronous, Lambdas
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Tes ting and D iagnos tic s
• Unit and functional test thoroughly!!
• Highest possible line coverage
• Utilize AWS SAM Local (a local CLI tool)
• Log generously
• Separate log from each instance :-(
• HomeAway uses Splunk to aggregate
• Consider
• AWS X-Ray
• IOpipe (only for JavaScript?)
AWS X-Ray
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Timeouts W ill H appen —Plan For Them
Happened during migration/high upload rates
Appeared to never start or never finish
Automatic retries meant no lost data
Never did find the cause
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Tip: Use dead letter queues!
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Stutter ing D ynamoD B Event Str eam
Erratic stream performance
(probably due to exceeding partition
capacity during high traffic migration)
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
D ynamoD B Str eam Wor k ar ound
Temporarily removed the dependency on DynamoDB streams
DynamoDB capacity is getting easier to manage (automated)
ODIS is now using the DynamoDB stream Lambda again
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Ending on a humorous note …
What happens when you require
1920 pixel wide photos from
your users?
H umans W ill Sur pr is e You!
© 2017 HOMEAWAY. ALL RIGHTS RESERVED.
Summing U p
Lambdas are great for:
• Event-driven systems
• Highly elastic loads
• Scheduled activities
• Rapid development
• Extensible designs
Use dead letter queues!
Does not fit every need
… use thoughtfully
Use DynamoDB auto-scaling
AWS X-Ray
Unit test thoroughly
Consider X-Ray
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Thank you!

Contenu connexe

Tendances

Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017
Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017
Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017Amazon Web Services
 
GPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsGPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsAmazon 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
 
GPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyGPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyAmazon Web Services
 
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost EfficiencyARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost EfficiencyAmazon Web Services
 
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017Amazon Web Services
 
CON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSCON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSAmazon 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
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural PatternsAmazon Web Services
 
Optimising Cost and Efficiency on AWS
Optimising Cost and Efficiency on AWSOptimising Cost and Efficiency on AWS
Optimising Cost and Efficiency on AWSAmazon Web Services
 
Building Serverless Real-time Data Processing (workshop)
Building Serverless Real-time Data Processing (workshop)Building Serverless Real-time Data Processing (workshop)
Building Serverless Real-time Data Processing (workshop)Amazon Web Services
 
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...Amazon Web Services
 
CMP211_Getting Started with Serverless Architectures
CMP211_Getting Started with Serverless ArchitecturesCMP211_Getting Started with Serverless Architectures
CMP211_Getting Started with Serverless ArchitecturesAmazon 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
 
How to Determine If You Are Well Architected for Resiliency (or How I Learned...
How to Determine If You Are Well Architected for Resiliency (or How I Learned...How to Determine If You Are Well Architected for Resiliency (or How I Learned...
How to Determine If You Are Well Architected for Resiliency (or How I Learned...Amazon Web Services
 
MCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiMCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiAmazon Web Services
 
CON203_Driving Innovation with Containers
CON203_Driving Innovation with ContainersCON203_Driving Innovation with Containers
CON203_Driving Innovation with ContainersAmazon Web Services
 
MBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldMBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldAmazon Web Services
 
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Amazon Web Services
 

Tendances (20)

Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017
Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017
Reinforcement Learning – The Ultimate AI - ARC320 - re:Invent 2017
 
GPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital MarketsGPSTEC305-Machine Learning in Capital Markets
GPSTEC305-Machine Learning in Capital Markets
 
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
 
GPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made EasyGPSWKS301_Comprehensive Big Data Architecture Made Easy
GPSWKS301_Comprehensive Big Data Architecture Made Easy
 
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost EfficiencyARC303_Running Lean Architectures How to Optimize for Cost Efficiency
ARC303_Running Lean Architectures How to Optimize for Cost Efficiency
 
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017
Create a Serverless Image Processing Platform - ARC326 - re:Invent 2017
 
CON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWSCON213_Hands-on Kubernetes on AWS
CON213_Hands-on Kubernetes on AWS
 
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
 
Serverless Architectural Patterns
Serverless Architectural PatternsServerless Architectural Patterns
Serverless Architectural Patterns
 
Optimising Cost and Efficiency on AWS
Optimising Cost and Efficiency on AWSOptimising Cost and Efficiency on AWS
Optimising Cost and Efficiency on AWS
 
Building Serverless Real-time Data Processing (workshop)
Building Serverless Real-time Data Processing (workshop)Building Serverless Real-time Data Processing (workshop)
Building Serverless Real-time Data Processing (workshop)
 
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...
GPSBUS220-Refactor and Replatform .NET Apps to Use the Latest Microsoft SQL S...
 
CMP211_Getting Started with Serverless Architectures
CMP211_Getting Started with Serverless ArchitecturesCMP211_Getting Started with Serverless Architectures
CMP211_Getting Started with Serverless Architectures
 
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
 
How to Determine If You Are Well Architected for Resiliency (or How I Learned...
How to Determine If You Are Well Architected for Resiliency (or How I Learned...How to Determine If You Are Well Architected for Resiliency (or How I Learned...
How to Determine If You Are Well Architected for Resiliency (or How I Learned...
 
MCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry PiMCL309_Deep Learning on a Raspberry Pi
MCL309_Deep Learning on a Raspberry Pi
 
CON203_Driving Innovation with Containers
CON203_Driving Innovation with ContainersCON203_Driving Innovation with Containers
CON203_Driving Innovation with Containers
 
MBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real WorldMBL201_Progressive Web Apps in the Real World
MBL201_Progressive Web Apps in the Real World
 
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
Building a Photorealistic Real-Time 3D Configurator with Server-Side Renderin...
 
SID402_An AWS Security Odyssey
SID402_An AWS Security OdysseySID402_An AWS Security Odyssey
SID402_An AWS Security Odyssey
 

Similaire à SRV315_How We Built a Mission-Critical, Serverless File Processing Pipeline for over 100 Million Photos

Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017
Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017
Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017Amazon Web Services
 
ATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsAmazon 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
 
DAT320_Moving a Galaxy into Cloud
DAT320_Moving a Galaxy into CloudDAT320_Moving a Galaxy into Cloud
DAT320_Moving a Galaxy into CloudAmazon 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
 
DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017Amazon Web Services
 
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...Amazon Web Services
 
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...Amazon Web Services
 
SRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsSRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsAmazon Web Services
 
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWS
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWSGPSWKS406-Migrating a Microsoft ASP.NET Application to AWS
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWSAmazon Web Services
 
AWS User Group Wellington - re:Invent 2017 Recap
AWS User Group Wellington - re:Invent 2017 RecapAWS User Group Wellington - re:Invent 2017 Recap
AWS User Group Wellington - re:Invent 2017 RecapAPI Talent
 
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...Amazon Web Services
 
ABD201-Big Data Architectural Patterns and Best Practices on AWS
ABD201-Big Data Architectural Patterns and Best Practices on AWSABD201-Big Data Architectural Patterns and Best Practices on AWS
ABD201-Big Data Architectural Patterns and Best Practices on AWSAmazon 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
 
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDSDAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDSAmazon Web Services
 
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...Amazon Web Services
 
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...Amazon Web Services
 
DAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudDAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudAmazon Web Services
 

Similaire à SRV315_How We Built a Mission-Critical, Serverless File Processing Pipeline for over 100 Million Photos (20)

Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017
Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017
Airbnb Runs on Amazon Aurora - DAT331 - re:Invent 2017
 
ATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing OperationsATC301-Big Data & Analytics for Manufacturing Operations
ATC301-Big Data & Analytics for Manufacturing Operations
 
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...
 
DAT320_Moving a Galaxy into Cloud
DAT320_Moving a Galaxy into CloudDAT320_Moving a Galaxy into Cloud
DAT320_Moving a Galaxy into Cloud
 
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
 
STG401_This Is My Architecture
STG401_This Is My ArchitectureSTG401_This Is My Architecture
STG401_This Is My Architecture
 
DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017DynamoDB - What's new - DAT304 - re:Invent 2017
DynamoDB - What's new - DAT304 - re:Invent 2017
 
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...
WIN301-Migrating Microsoft SQL Server Databases to AWS-Best Practices and Pat...
 
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...
Migrating Microsoft SQL Server Databases to AWS – Best Practices and Patterns...
 
SRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless ApplicationsSRV313_Building Resilient, Multi-Region Serverless Applications
SRV313_Building Resilient, Multi-Region Serverless Applications
 
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWS
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWSGPSWKS406-Migrating a Microsoft ASP.NET Application to AWS
GPSWKS406-Migrating a Microsoft ASP.NET Application to AWS
 
AWS User Group Wellington - re:Invent 2017 Recap
AWS User Group Wellington - re:Invent 2017 RecapAWS User Group Wellington - re:Invent 2017 Recap
AWS User Group Wellington - re:Invent 2017 Recap
 
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...
Tinder and DynamoDB: It's a Match! Massive Data Migration, Zero Down Time - D...
 
ABD201-Big Data Architectural Patterns and Best Practices on AWS
ABD201-Big Data Architectural Patterns and Best Practices on AWSABD201-Big Data Architectural Patterns and Best Practices on AWS
ABD201-Big Data Architectural Patterns and Best Practices on AWS
 
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
 
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDSDAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
DAT309_Best Practices for Migrating from Oracle and SQL Server to Amazon RDS
 
HLC308_Refactoring to the Cloud
HLC308_Refactoring to the CloudHLC308_Refactoring to the Cloud
HLC308_Refactoring to the Cloud
 
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
Healthcare Payers and Serverless Batch Processing Engines - HLC308 - re:Inven...
 
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...
From Mainframe to Microservices: Vanguard’s Move to the Cloud - ENT331 - re:I...
 
DAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the CloudDAT317_Migrating Databases and Data Warehouses to the Cloud
DAT317_Migrating Databases and Data Warehouses to the Cloud
 

Plus de Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateAmazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSAmazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsAmazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareAmazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSAmazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAmazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareAmazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceAmazon Web Services
 

Plus 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
 

SRV315_How We Built a Mission-Critical, Serverless File Processing Pipeline for over 100 Million Photos

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS re:INVENTHow We Built a Mission-Critical, Serverless File Processing Pipeline for over 100 Million Photos M i k e B r o a d w a y , P r i n c i p a l A r c h i t e c t , H o m e A w a y N o v e m b e r 2 7 , 2 0 1 7
  • 2. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. About Me —Mik e Br oadw ay A recovering start-up junkie Designing and writing software for ~40 years • Mainframe device drivers, word processors, terminal emulators, financial planners, job schedulers, etc. A Principal Architect at HomeAway, Expedia • Focus on content, media, identity, communications, etc. • Anything that is not UX or payment-related
  • 3. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. W hat I W ill Talk About • Why we needed a new photo storage system • How we met that need with AWS Serverless • Amazon Simple Storage Service (S3), AWS Lambdas, Amazon DynamoDB, Amazon Kinesis, etc. • The best practices that we learned
  • 4. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Shor t Shelf Life War ning AWS is iterating rapidly … … this talk will be out of date soon
  • 5. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. H omeAw ay– A Vac ation R ental Mar k etplac e 2 million places to stay in 190 countries
  • 6. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. H omeAw ay H as a Lot of Photos !
  • 7. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. H ow Many Photos ? • ~ 6 million original image uploads/month • ~ 5 terabytes/month • ~ 80 million unique originals • ~ 1.5 billion “treatment” derivatives
  • 8. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. H ow D id H omeAw ay Manage Images Befor e? • A farm of Java application servers in Austin • Implemented nine years ago • Design goals defined for acquired brands • Network Attached Storage/NFS
  • 9. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Pr evious Image Sys tem —Expens ive & D ated Pricey top tier network storage … $5,000/terabyte $20,000 to $25,000/month Hard-coded treatment sizes 4x3 aspect ratio 1024 largest width then now
  • 10. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. H ighly Var iable U pload Volume Image uploads/hour over one week Nine image uploads per second @ 12:03 p.m. Saturday Even the smaller peaks are a doubling and tripling of traffic 225:1 Load Ratio 25 seconds between image uploads @ 00:40 a.m. Monday
  • 11. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. We U pgr aded to an AW S Ser ver les s Solution • AWS Lambda for extreme scalability • Amazon S3 to address the storage costs • DynamoDB for metadata and treatment definitions • Multi-region for high availability
  • 12. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. A Ver y Shor t Intr oduc tion to AW S Lambda
  • 13. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. • Single function code blocks • No threads to manage • No server patches to apply • Fine-grained scaling • Only runs when triggered • Only pay for what runs AW S Lambda Over view
  • 14. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. 'use strict'; exports.lambda_handler = function(event, context, callback) { var message = event.Records[0].Sns.Message; console.log('Message received from SNS:', message); callback(null, "Success"); }; Tr ivial J avaSc r ipt Example … logs the content of an SNS message
  • 15. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. @Override public Response handleRequest(SNSEvent event, Context context) { return handleSNSEvent(event, context, Disposition.class, disposition -> { if (disposition.getStatusFlag().equals(Disposition.Status.DEPRECATED)) { ... logging ... return; } if (isBlacklistedPhoto(disposition)) { throw new ErrorResponseException(... description ...); } ... logging ... BucketDescriptor sourceBucketDescriptor = new BucketDescriptor(getBusinessDescriptor(), getEnvironmentDescriptor(), BucketDescriptor.Type.MASTER); ImageFileDescriptor sourceImageFileDescriptor = new ImageFileDescriptor(sourceBucketDescriptor, disposition.getS3Key()); getTreatmentProcessor().renderTreatmentSets(sourceImageFileDescriptor, disposition); }); } An Image Manipulation Lambda
  • 16. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. OD IS: On D emand Image Ser vic e
  • 17. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. The OD IS Image Pipeline 6000 x 4000 Original 2880 x 1920 Master Client ready “treatments” Induction λ Treatment caching λ S3 S3 S3
  • 18. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Thr ee S3 Buc k ets — Thr ee Stages
  • 19. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Adding Or iginal Images
  • 20. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. D er iving the “ Mas ter ”
  • 21. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. R ec or ding The Initial “ D is pos ition”
  • 22. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. R eac ting to a N ew Image D is pos ition
  • 23. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Pr e - C a c h in g Se le c te d Ima g e Tr e a tme n ts NOTE: named “treatment definitions” are stored in a second DynamoDB table (not shown)
  • 24. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Ser ving Images to the C D N
  • 25. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. R es ponding to C ac he Mis s es
  • 26. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Alter ing an Image D is pos ition
  • 27. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Keeping the C lient Platfor m Infor med
  • 28. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Analyz ing Image C ontent and Quality
  • 29. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Benefits of AW S Ser ver les s for OD IS • Ultra fine-grained scalability • Event-driven • Rapid development • Naturally flexible/extensible design • Significant cost savings • ~$5,000/month as opposed to > $25,000/month • Simplified operations • No patching, no server monitoring, etc.
  • 30. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Bes t Pr ac tic es Lear ned
  • 31. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Lambdas Ar e Als o Good for Sc heduled Tas k s • Can schedule Lambdas to run at intervals or time • At specified rate: rate(1 hour) • At specified time: cron(0 17 ? * MON-FRI *) • No need to have a server just to schedule a job • Startup cost is irrelevant for such one-offs • Not so much for long running jobs
  • 32. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Amaz on API Gatew ay API Gateway interfaces are always public
  • 33. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Mor e C an Be Les s • Initially, we minimized Lambda memory • Lower memory = lower cost per 100ms • But CPU is allocated proportionally • Twice the memory = twice the CPU • We saved money by configuring more memory! • More memory = more CPU = shorter duration • Optimize by experimentation
  • 34. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Lambda Spin - U p & R eus e Duration of the main, image processing, ODIS Lambdas • Average: ~2.5 seconds • First invocation: 10 to 12 seconds (GraphicsMagick, etc., setup) Spiky traffic patterns may not allow start up costs to be amortized
  • 35. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Only Inc lude W hat You N eed! • Lambda jar/zip files must be less than 50 MB • Java dependencies can add up! • Use the Maven Shade or Gradle Shadow plugin Maven Shade
  • 36. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. One Pr ojec t to R ule Them All • Keep it all together • A single github project • A single jar file/single deployment package • Greatly simplifies management • Simpler testing and version control
  • 37. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. D eletion & Amaz on S3 Ver s ioning 82 million master images Ramp up during migration from Austin data center 193 million original images??? Duh! Deletes are soft when S3 versioning is enabled Master bucket object count
  • 38. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Lambda Thr ottling • Account-wide limit on concurrent Lambdas • Limit is per region, can be different across regions • Now defaults to 1,000 (can request more) • HomeAway currently at 1,500
  • 39. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Worse: it could be another product and another team in the same account A surge here … … starvation there Lambda Thr ottling Pain
  • 40. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. D ynamoD B Str eam H andling Stream processing can be a bottleneck • Minimize per event processing times • Fan out to other, asynchronous, Lambdas
  • 41. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Tes ting and D iagnos tic s • Unit and functional test thoroughly!! • Highest possible line coverage • Utilize AWS SAM Local (a local CLI tool) • Log generously • Separate log from each instance :-( • HomeAway uses Splunk to aggregate • Consider • AWS X-Ray • IOpipe (only for JavaScript?) AWS X-Ray
  • 42. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Timeouts W ill H appen —Plan For Them Happened during migration/high upload rates Appeared to never start or never finish Automatic retries meant no lost data Never did find the cause
  • 43. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Tip: Use dead letter queues!
  • 44. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Stutter ing D ynamoD B Event Str eam Erratic stream performance (probably due to exceeding partition capacity during high traffic migration)
  • 45. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. D ynamoD B Str eam Wor k ar ound Temporarily removed the dependency on DynamoDB streams DynamoDB capacity is getting easier to manage (automated) ODIS is now using the DynamoDB stream Lambda again
  • 46. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Ending on a humorous note … What happens when you require 1920 pixel wide photos from your users? H umans W ill Sur pr is e You!
  • 47. © 2017 HOMEAWAY. ALL RIGHTS RESERVED. Summing U p Lambdas are great for: • Event-driven systems • Highly elastic loads • Scheduled activities • Rapid development • Extensible designs Use dead letter queues! Does not fit every need … use thoughtfully Use DynamoDB auto-scaling AWS X-Ray Unit test thoroughly Consider X-Ray
  • 48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Thank you!