getting started with serverless architectures
TRANSCRIPT
![Page 1: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/1.jpg)
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Andrew Baird, Solutions Architect, AWS
August 2016
Getting Started with
Serverless Architectures
![Page 2: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/2.jpg)
Agenda
Background
AWS Lambda
Amazon API Gateway
Demo
Serverless Architecture Patterns
Serverless Best Practices
![Page 3: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/3.jpg)
BackgroundHow serverless architecture patterns with AWS Lambda are the next
evolution of application design
![Page 4: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/4.jpg)
The Monolithic Architecture
![Page 5: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/5.jpg)
The Service-Oriented Architecture
Presentation Tier Logic Tier
Data Tier
![Page 6: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/6.jpg)
The Microservices Architecture
![Page 7: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/7.jpg)
Tools to Help This Pattern are VAST
Web servers
Code libraries
Web service/application frameworks
Configuration management tools
API management platforms
Deployment patterns
CI/CD patterns
Containers
Etc. Etc. Etc.
![Page 8: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/8.jpg)
AWS Has Helped Too!
Amazon EC2
Auto Scaling
Elastic Load Balancing
Amazon EC2 auto recovery
AWS Trusted Advisor
AWS Elastic Beanstalk
AWS OpsWorks
Amazon ECS
Etc. Etc. Etc.
![Page 9: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/9.jpg)
But….
many of these tools and
innovations are still coupled to
a shared dependency…
![Page 10: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/10.jpg)
Servers (AAHHHHHHHHH!!)
What size servers are right for
my budget?
How many users create too
much load for my servers?
How much remaining capacity
do my servers have?
How can I detect if a server has
been compromised?
How many servers
should I budget for?
Which OS should my
servers run?
Which users should have
access to my servers?
How can I control access from
my servers?
How will I keep my server
OS patched?
How will new code be
deployed to my servers?
How can I increase
utilization of my servers?
When should I decide to
scale out my servers?
What size server is
right for my performance?
Should I tune OS settings
to optimize my application?
Which packages should be
baked into my server images?
When should I decide to
scale up my servers?
How should I handle server
configuration changes?
How will the application handle
server hardware failure?
![Page 11: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/11.jpg)
Architect to be Serverless
Fully managed
• No provisioning
• Zero administration
• High availability
Developer productivity
• Focus on the code that
matters
• Innovate rapidly
• Reduce time to market
Continuous scaling
• Automatically
• Scale up and scale down
![Page 12: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/12.jpg)
AWS Lambda
![Page 13: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/13.jpg)
Serverless, event-driven compute service
Lambda = microservice without servers
![Page 14: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/14.jpg)
Components of Lambda
• A Lambda function (that you write)
• An event source
• The AWS Lambda service
• The function networking environment
![Page 15: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/15.jpg)
Lambda Function
• Your code
(Java, NodeJS, Python)
• The IAM role that code
assumes during execution
• The amount of memory
allocated to your code
(affects CPU and network
as well)
A valid, complete
Lambda function
![Page 16: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/16.jpg)
Event Sources
• When should your function
execute?
• Many AWS services can be
an event source today:
• Amazon S3
• Amazon Kinesis
• Amazon SNS
• Amazon DynamoDB
• Amazon CloudWatch
• AWS Config Rules
• Amazon Echo
• Etc.
• …and Amazon API
Gateway (more later)
![Page 17: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/17.jpg)
AWS Lambda
• Runs your function code without you managing or
scaling servers.
• Provides an API to trigger the execution of your function.
• Ensures function is executed when triggered, in parallel,
regardless of scale.
• Provides additional capabilities for your function
(logging, monitoring).
![Page 18: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/18.jpg)
Function Networking Environment
Default - a default network
environment within VPC is
provided for you
• Access to the Internet always
permitted to your function
• No access to VPC-deployed assets
Customer VPC - Your function
executes within the context of your own VPC.
• Privately communicate with other
resources within your VPC.
• Familiar configuration and behavior
with:
– Subnets
– Elastic network interfaces (ENIs)
– EC2 security groups
– VPC route tables
– NAT gateway
![Page 19: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/19.jpg)
“Hold on…” – you (maybe)
![Page 20: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/20.jpg)
Lots of Existing Ways to Abstract Away Servers
SaaS
PaaS
MBaaS
*aaS
Application Engines/Platforms
![Page 21: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/21.jpg)
What’s Unique About Lambda?
Abstraction at the code/function level (arbitrary, flexible,
familiar)
The security model (IAM, VPC)
The pricing model
The community
Integration with the AWS service ecosystem!
• Scale
• Triggers
![Page 22: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/22.jpg)
Many Serverless Options on AWS
Storage DatabaseNetwork
Compute Content DeliveryMessaging and QueuesSecurity
Gateways
User Management Monitoring & Logging
Internet of Things
Machine Learning
Streaming Analytics
![Page 23: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/23.jpg)
Example Serverless
Architecture
![Page 24: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/24.jpg)
PlayOn! Sports – Video Stream Processing
Laptop
Encoders
HLS
S3
Playback
VOD Stream
mobile client
CloudFront
Streaming
Live stream
mobile client
CloudFront S3 Ingest
480p
Transcode
HQ Copy
360p
Transcode
Audio-only
Transcode
Thumbnail
QOS
Analytics
Cascading Lambda Functions
http://www.slideshare.net/AmazonWebServices/arc308-the-serverless-company-using-aws-lambda
![Page 25: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/25.jpg)
“But…
in order to utilize Lambda, do I really
need to architect event-driven
applications?” – you (maybe)
![Page 26: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/26.jpg)
SOA still works.
![Page 27: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/27.jpg)
Amazon API Gateway
![Page 28: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/28.jpg)
A Fully Managed Service for Your APIs
Create Configure Publish
Maintain Monitor Secure
![Page 29: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/29.jpg)
Demo
AWS Lambda
function
web browser
Amazon S3
Dynamic content
Serverless website
Amazon API
Gateway
Static content
Amazon
DynamoDB
![Page 30: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/30.jpg)
![Page 31: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/31.jpg)
![Page 32: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/32.jpg)
![Page 33: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/33.jpg)
![Page 34: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/34.jpg)
![Page 35: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/35.jpg)
![Page 36: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/36.jpg)
![Page 37: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/37.jpg)
![Page 38: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/38.jpg)
![Page 39: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/39.jpg)
![Page 40: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/40.jpg)
![Page 41: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/41.jpg)
![Page 42: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/42.jpg)
![Page 43: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/43.jpg)
![Page 44: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/44.jpg)
![Page 45: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/45.jpg)
![Page 46: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/46.jpg)
![Page 47: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/47.jpg)
![Page 48: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/48.jpg)
![Page 49: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/49.jpg)
![Page 50: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/50.jpg)
![Page 51: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/51.jpg)
![Page 52: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/52.jpg)
![Page 53: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/53.jpg)
![Page 54: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/54.jpg)
![Page 55: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/55.jpg)
![Page 56: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/56.jpg)
![Page 57: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/57.jpg)
![Page 58: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/58.jpg)
![Page 59: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/59.jpg)
![Page 60: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/60.jpg)
![Page 61: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/61.jpg)
![Page 62: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/62.jpg)
![Page 63: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/63.jpg)
![Page 64: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/64.jpg)
![Page 65: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/65.jpg)
![Page 66: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/66.jpg)
![Page 67: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/67.jpg)
![Page 68: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/68.jpg)
![Page 69: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/69.jpg)
![Page 70: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/70.jpg)
![Page 71: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/71.jpg)
Serverless Architecture Patterns
![Page 72: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/72.jpg)
Microservices
![Page 73: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/73.jpg)
Mobile Backend
![Page 74: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/74.jpg)
Real-time Analytics Engine
![Page 75: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/75.jpg)
Serverless Best Practices
![Page 76: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/76.jpg)
AWS Lambda Best Practices
1. Limit your function size –
especially for Java (starting
the JVM takes time).
2. Node – remember execution
is asynchronous.
3. Don’t assume function
container reuse – but take
advantage of it when it does
occur.
4. Don’t forget about disk (500
MB /tmp directory provided to
each function).
5. Use function aliases for
release.
6. Use the included logger
(include details from service-
provided context).
7. Create custom metrics
(operations-centric, and
business-centric).
![Page 77: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/77.jpg)
Amazon API Gateway Best Practices
4. Use request/response
mapping templates
everywhere within reason, not
passthrough.
5. Take ownership of HTTP
response codes.
6. Use Swagger import/export
for cross-account sharing.
1. Use mock integrations
2. Combine with Amazon
Cognito for managed end
user-based access control.
3. Use stage variables (inject
API config values into
Lambda functions for logging,
behavior).
![Page 78: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/78.jpg)
Additional Best Practices
1. Use strategic, consumable
naming conventions (Lambda
function names, IAM roles,
API names, API stage names,
etc.).
2. Use naming conventions and
versioning to create
automation.
3. Externalize authorization to
IAM roles whenever possible.
4. Least privilege and separate
IAM roles.
5. Externalize configuration –
DynamoDB is great for this.
6. Contact AWS Support before
known large scaling events.
7. Be aware of service throttling,
engage AWS support if so.
![Page 79: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/79.jpg)
A Call to Action
![Page 80: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/80.jpg)
Go build something!
Amazon API
GatewayAWS Lambda Amazon
DynamoDB
![Page 81: Getting Started with Serverless Architectures](https://reader031.vdocuments.us/reader031/viewer/2022021922/586fb3ec1a28abe57d8b6e95/html5/thumbnails/81.jpg)
Thank you!