With serverless computing, you can build and run applications without the need for provisioning or managing servers. Serverless computing means that you can build web, mobile, and IoT backends, run stream processing or big data workloads, run chatbots, and more. In this session, learn how to get started with serverless computing with AWS Lambda, which lets you run code without provisioning or managing servers. We introduce you to the basics of building with Lambda. As part of that, we show how you can benefit from features such as continuous scaling, built-in high availability, integrations with AWS and third-party apps, and subsecond metering pricing. We also introduce you to the broader portfolio of AWS services that help you build serverless applications with Lambda, including Amazon API Gateway, Amazon DynamoDB, AWS Step Functions, and more.
12. Lambda execution model
Synchronous (push) Asynchronous (event) Stream-based
Amazon
API Gateway
Lambda
function
Amazon
DynamoDBAmazon
SNS
/order
Lambda
function
Amazon
S3
Reqs
Amazon
Kinesis
Changes
AWS Lambda
service
Function
14. Lambda permissions model
Fine-grained security controls for both
execution and invocation:
Execution policies:
• Define what AWS resources/API calls can this
function access through IAM
• Used in streaming invocations
• E.g. ,“Lambda function A can read from
DynamoDB table users”
Function policies:
• Used for sync and async invocations
• E.g., “Actions on bucket X can invoke Lambda
function Z"
• Resource policies allow for cross-account
access
15. Amazon API Gateway
Internet
Mobile Apps
Websites
Services
AWS Lambda
functions
AWS
All publicly
accessible
endpoints
Amazon
CloudWatch
monitoring
Amazon
CloudFront
Any other
AWS service
Endpoints on
Amazon EC2
AWS Step
Functions
17. AWS Step Functions
“Serverless” workflow management with
zero administration:
• Makes it easy to coordinate the
components of distributed applications
and microservices using visual
workflows
• Automatically triggers and tracks each
step, and retries when there are errors,
so your application executes in order
and as expected
• Logs the state of each step, so when
things do go wrong, you can diagnose
and debug problems quickly
Task
Choice
Failure capture
Parallel tasks
19. “Can I go ahead
with the booking?
“Book a Hotel”
“Book a Hotel in
NYC”
Automatic Speech
Recognition
Hotel Booking
New York City
Natural Language
Understanding
Intent/Slot
Model
UtterancesHotel Booking
City New York City
Check in Nov 30th
Check out Dec 2nd
“Your hotel is booked for
Nov 30th”
Amazon Polly
Confirmation: “Your hotel
is booked for Nov 30th”
Book Hotel
NYC
a
in
20. Amazon
Kinesis
AWS
Lambda 1
Amazon
CloudWatch
Amazon
DynamoDB
AWS
Lambda 2 Amazon
S3
Real-time data processing:
1. Real-time event data sent to Amazon Kinesis,
allows multiple AWS Lambda functions to
process the same events.
2. In AWS Lambda, Function 1 processes and
aggregates data from incoming events, then
stores result data in Amazon DynamoDB
3. Lambda Function 1 also sends values to
Amazon CloudWatch for simple monitoring of
metrics.
4. In AWS Lambda function, Function 2 does data
manipulation of incoming events and stores
results in Amazon S3
https://s3.amazonaws.com/awslambda-reference-architectures/stream-processing/lambda-refarch-streamprocessing.pdf
AWS Lambda + Amazon Kinesis
21. Serverless distributed computing: PyWren
PyWren Prototype developed at University of California, Berkeley
Uses Python with AWS Lambda stateless functions for large-scale data
analytics
Achieved @ 30-40 MB write and read performance per-core to Amazon S3
object store
Scaled to 60-80 GB across 2,800 simultaneous functions
22. Build PCI and HIPAA-compliant serverless applications!
Serverless platform services that can be used in both:
AWS
Lambda
Amazon
S3
Amazon
CloudFront
Amazon
DynamoDB
Amazon
Kinesis
Streams
Amazon
Cognito
Amazon API
Gateway
Amazon
SNS
23. Where do you ..
https://secure.flickr.com/photos/stevendepolo/5749192025/
25. Claudia.js
Node.js framework for deploying
projects to AWS Lambda and
Amazon API Gateway
• Has sub-projects for
microservices, chatbots, and APIs
• Simplified deployment with a
single command
• Use standard NPM packages, no
need to learn Swagger
• Manage multiple versions
https://claudiajs.com
https://github.com/claudiajs/claudia $ claudia create --region us-east-1 --api-module app
26. Chalice
Python serverless “microframework”
for AWS Lambda and Amazon API
Gateway
• A command line tool for creating,
deploying, and managing your
app
• A familiar and easy-to-use API for
declaring views in python code
• Automatic Amazon IAM policy
generation
https://github.com/aws/chalice
https://chalice.readthedocs.io $chalice deploy
Chalice
30. SAM template
Tells AWS CloudFormation this is a
SAM template it needs to
“transform.”
Creates a Lambda function with the
referenced managed IAM policy,
runtime, code at the referenced .zip
location, and handler as defined.
Also creates an API Gateway and
takes care of all necessary
mapping/permissions.
Creates a DynamoDB table with five
Read & Write units.
32. Introducing SAM Local
CLI tool for local testing of serverless apps
Works with Lambda functions and “proxy-
style” APIs
Response object and function logs
available on your local machine
Uses open-source docker-lambda images
to mimic Lambda’s execution environment:
• Emulates timeout, memory limits,
runtimes
https://github.com/awslabs/aws-sam-local
35. Capital One
• T o p 1 0 U. S. Bank
• A l e xa W e b si te
Ranki ng says
c ap i tal o ne . c o m
tr af f i c i s “ 8 1 st i n
U . S. we b si te s”
• A uto F i nanc i ng – 1 M
hi ts/ m o nth
37. Migration Requirements
• Full functionality and more
• Secure – yes, we actually are a Financial Institution
• Resilient (Active/Active)
• Responsive – front-facing Marketing Home Page, so initial load time is critical
• SEO friendly
• Continuous deployments – changes on demand
• Low maintenance – it just needs to run
• Use existing tools and processes in the enterprise – don’t re-invent the wheel
• Logging
• Monitoring
• Deployments
38. The Painful Old Days
• H o s t e d i n o n - p r e m i s e s
d a t a c e n t e r
• E n t e r p r i s e - w i d e
c o m m o n d e p l o y m e n t s
• O n e c a l e n d a r ─
f e a t u r e s p l a n n e d
m o n t h s i n a d v a n c e
• T i g h t c o u p l i n g
b e t w e e n c o m p o n e n t s
Web Browser
Oracle WebLogic Server
J2EE Application Server
Web Container
Servlets
JSPs
EJB Container
Session EJBs
Entity JSPs
JAX-RPC
JDBC JMS
JNDIJMX
JTA
RDBMS
Directory
Service
Message
Queue
Web
Services
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
40. App architecture—content
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
Amazon
Route 53
Amazon S3
Amazon S3
East Region
West Region
Amazon
CloudFront
Amazon
CloudFront
41. Amazon
Route 53
Rest APIs
EC2
EC2
EC2
EC2
WAF App
AZ1
AZ2
AZ3
East
EC2
EC2
EC2
EC2
WAF App
AZ1
AZ2
AZ3
West
App Architecture – APIs
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
42. CI/CD for Content
• A p p t e m p l a t e s i n
G i t H u b
• C o n t e n t i n C M S h o s t e d
s e r v i c e
• P r e - r e n d e r a n g u l a r
c o n t e n t ; S E O F r i e n d l y
• U s e A W S C L I t o p u s h
c o n t e n t t o S 3 b u c k e t
f o r w e b h o s t i n g
Content Management
System
AWS CLI
Amazon EC2
Build Server
Content S3 Bucket
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
44. Move to Serverless APIs
Amazon
Route 53
Rest APIs
CapOne
Enterprise
Gateway
Lambda
Fn
Amazon
CloudWatch
Lambda
Fn
East
CapOne
Enterprise
Gateway
Lambda
Fn
Amazon
CloudWatch
Lambda
Fn
West
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
45. CI/CD – Lambda Functions
AWS CLI
Deployment S3 Bucket
Lambda Create
Lambda Update
Lamba Fn
• L a m b d a c o d e i n G i t H u b
• J e n k i n s t r i g g e r e d b u i l d
• U s e s A W S C L I
• D e p l o y i n S 3 b u c k e t
• C r e a t e / u p d a t e
L a m b d a f u n c t i o n
• O t h e r o p t i o n s :
• S A M
• S e r v e r l e s s f r a m e w o r k
Serverless - I
2015 August
2016
April
2017
Server Based Serverless - II
46. Benefits of Serverless
• Super simple architecture
• Runs itself, less monitoring
• Scales itself, no work on Auto Scaling needed
• No worries on AMI rehydration, which keeps compliance and
operations happy
• Cost savings:
• Conservative savings to tune of $50K/year
• Amazon S3 web hosting eliminated any Amazon EC2 needs for
website hosting
• Able to eliminate 20 EC2 instances, CLBs, EBS volumes from API
architecture
• Countless hours saved on operations of application
47. Lessons Learned
• Migration can be a journey, so plan accordingly
• Step-by-step progress is recommended
• Start small
• Serverless architectures are flexible and fungible
• No one size fits all
• Reuse tools and processes in the organization
• Get stakeholder buy-in early