getting started with serverless architectures
TRANSCRIPT
![Page 1: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/1.jpg)
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Vyom Nagrani
Manager Product Management, AWS Lambda
30th March, 2016
Getting Started with
Serverless Architectures
![Page 2: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/2.jpg)
Agenda
Background
AWS Lambda
Amazon API Gateway
Serverless Architecture Patterns
Serverless Best Practices
![Page 3: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/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://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/4.jpg)
The Monolithic Application
![Page 5: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/5.jpg)
The Monolithic Application
• Lots of Collateral Damage
• All-for-one and one-to-fail
• Slipped timelines
• Operational issues
• Deploy Less Frequently
• Less disruption
• More time to plan
Reduce Risk
![Page 6: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/6.jpg)
Break it apart.
![Page 7: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/7.jpg)
The Monolithic Architecture
![Page 8: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/8.jpg)
The Service Oriented Architecture
Presentation TierLogic Tier
Data Tier
![Page 9: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/9.jpg)
The Microservices Architecture
![Page 10: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/10.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
… and so on
![Page 11: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/11.jpg)
AWS has helped too!
Amazon EC2
EC2 Auto-Scaling
AWS Elastic Load Balancer
EC2 Auto-Recovery
AWS Trusted Advisor
AWS Elastic Beanstalk
AWS OpsWorks
AWS EC2 Container Service
Etc. Etc. Etc.
![Page 12: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/12.jpg)
But …
many of these tools and innovations are still
coupled to a shared dependency…
![Page 13: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/13.jpg)
ServersHow will the application
handle server hardware failure?
How can I control
access from my servers?
When should I decide to
scale out my servers?
When should I decide to
scale up my servers?What size servers are
right for my budget?
How much remaining
capacity do my servers have?
(AAHHHHHHHHH!!)
![Page 14: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/14.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 15: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/15.jpg)
Serverless, event-driven compute service
Lambda = microservice without servers
Enter AWS Lambda
![Page 16: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/16.jpg)
Components of Lambda
A Lambda Function (that you write)
An Event Source
The AWS Lambda Service
The Function Networking Environment
![Page 17: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/17.jpg)
The 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 18: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/18.jpg)
An Event Source
Many AWS services can be an event source today:
S3
Kinesis
SNS
DynamoDB
CloudWatch
Config Rules
Amazon Al
… and many more
…and, of course, Amazon API Gateway (more later)
![Page 19: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/19.jpg)
The AWS Lambda Service
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 20: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/20.jpg)
The 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 21: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/21.jpg)
“Hold on…”
![Page 22: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/22.jpg)
Lots of existing ways to abstract away servers
SaaS
PaaS
MBaaS
*aaS
Application Engines/Platforms
![Page 23: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/23.jpg)
What’s unique about Lambda?
Abstraction at the code/function level (arbitrary, flexible,
familiar)
The security model (IAM, VPC)
The community
Integration with the AWS Service ecosystem!
Scale
Triggers
The pricing model
![Page 24: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/24.jpg)
Continuous
Scaling
No Servers to
ManageSubsecond
Metering
Benefits of AWS Lambda for building
serverless backends
1 2 3
![Page 25: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/25.jpg)
Many Serverless Options on AWS
Compute StorageDatabase
Network
Gateways
Internet of Things
Messaging and Queues
Machine LearningStreaming Analytics
Content Delivery
Security
User Management
Monitoring & Logging
![Page 26: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/26.jpg)
Example Serverless
Architecture
![Page 27: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/27.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 28: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/28.jpg)
But…
… in order to utilize Lambda, do I really need to architect
event-driven applications?
… is there a way I can use this construct to built multi-
tier SOA applications?
![Page 29: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/29.jpg)
Enter Amazon API Gateway
Create Configure Publish
Maintain Monitor Secure
![Page 30: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/30.jpg)
Serverless Architecture Patterns
![Page 31: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/31.jpg)
Microservices
![Page 32: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/32.jpg)
Mobile Backend
![Page 33: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/33.jpg)
Web Applications
![Page 34: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/34.jpg)
Real-time Analytics Engine
![Page 35: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/35.jpg)
Serverless Best Practices
![Page 36: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/36.jpg)
AWS Lambda Best Practices
Limit your function size – especially for Java (starting the JVM
takes time)
Node – remember execution is asynchronous.
Don’t assume function container reuse – but take advantage of it
when it does occur.
Don’t forget about disk (500MB /tmp directory provided to each
function)
Use the included logger (include details from service-provided
context)
Create custom metrics (operations-centric, and business-centric)
![Page 37: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/37.jpg)
Amazon API Gateway Best Practices
Use Mock integrations
Combine with Cognito for managed end user-based access control.
Use stage variables (inject API config values into Lambda functions
for logging, behavior)
Use request/response mapping templates everywhere within
reason, not passthrough.
Take ownership of HTTP response codes
Use Swagger import/export for cross-account sharing
![Page 38: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/38.jpg)
Additional Best Practices
Use strategic, consumable naming conventions (Lambda function
names, IAM roles, API names, API stage names, etc.)
Use naming conventions and versioning to create automation.
Externalize authorization to IAM roles whenever possible
Least privilege and separate IAM roles
Externalize configuration – DynamoDB is great for this.
Contact AWS Support before known large scaling events
Be aware of service throttling, engage AWS support if so.
![Page 39: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/39.jpg)
A Call to Action
![Page 40: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/40.jpg)
Let’s build something Serverless …
AWS Lambda
Function
web browser
Amazon S3
Amazon API
Gateway
Dynamic Content
Serverless Website
Amazon
DynamoDB
https://aws.amazon.com/blogs/compute/the-squirrelbin-architecture-a-
serverless-microservice-using-aws-lambda/
![Page 41: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/41.jpg)
<shameless-pitch>
In case you didn’t guess …
We’re hiring!
Email [email protected]
</shameless-pitch>
![Page 42: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/42.jpg)
Thank you!
https://www.linkedin.com/in/vyomnagrani
@vyomnagrani
![Page 43: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/43.jpg)
Demo
![Page 44: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/44.jpg)
Walkthrough of a simple CRUD backend with a
RESTful API endpoint using AWS Lambda
Amazon API
Gateway
AWS Lambda Amazon
DynamoDB
API call from
client app
Request/Response CRUD Operations
![Page 45: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/45.jpg)
![Page 46: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/46.jpg)
![Page 47: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/47.jpg)
CRUD operations with DynamoDB
‘echo’ and ‘pong’ for testing
Error handling for incorrect inputs
Execute the operation with the event payload
![Page 48: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/48.jpg)
![Page 49: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/49.jpg)
![Page 50: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/50.jpg)
![Page 51: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/51.jpg)
![Page 52: Getting Started with Serverless Architectures](https://reader034.vdocuments.us/reader034/viewer/2022051521/5873be7b1a28abbc788b5f01/html5/thumbnails/52.jpg)