Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS...
Transcript of Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS...
![Page 1: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/1.jpg)
©2015, Amazon Web Services, Inc. or its affiliates. All rights reserved
Microservices without the Servers:
AWS Lambda in Action
Dr. Tim Wagner, General Manager AWS Lambda
August 19, 2015 | Seattle, WA
![Page 2: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/2.jpg)
Two Minute AWS Lambda
Origin Story
![Page 3: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/3.jpg)
Evolution of Storage
Data Center
Disks
Objects (files)
![Page 4: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/4.jpg)
Evolution of Storage: Cloud Store
Amazon S3
![Page 5: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/5.jpg)
Sharing = Lower Costs
Amazon S3
![Page 6: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/6.jpg)
Evolution of Storage Compute
Data Center
Server Racks / VMs
Functions
![Page 7: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/7.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
Containers
![Page 8: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/8.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
![Page 9: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/9.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
![Page 10: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/10.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
Containers
![Page 11: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/11.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
Containers
![Page 12: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/12.jpg)
Evolution of Compute
Amazon EC2 Container Service (ECS)
Containers
![Page 13: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/13.jpg)
Evolution of Compute: Lambda
AWS Lambda
![Page 14: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/14.jpg)
Sharing = Lower Costs
AWS Lambda
![Page 15: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/15.jpg)
Build an image-processing microservice that…
Scales per request
Can run native binaries and executables/processes
Requires no deployment effort
Fault tolerant and multi-region
Includes both web and mobile clients
The 2015 LinuxCon Challenge
![Page 16: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/16.jpg)
Do it without:
Servers
Monolithic app or explicit web service
Explicit code for scaling or fault tolerance
Paying for idle time
…and get it done in 45 minutes!
The Catch
![Page 17: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/17.jpg)
Serverless Microservice Architecture
Static web content
served from
Amazon S3
AWS Lambda
+ ImageMagick
Web Client
Amazon API
Gateway
Mobile Client
![Page 18: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/18.jpg)
Step 1
An ImageMagick Server
in AWS Lambda
![Page 19: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/19.jpg)
What we’re going to do
1. Create an AWS Lambda function1. Choice of languages (Java, nodejs, Scala, Clojure, …). We’ll
use nodejs to make it easy to edit in the console.
2. With nodejs on Lambda, ImageMagick is built in…but you
could also use PIL or 3rd party libraries (even native ones).
2. Add a little code to indicate which command to
run (convert, thumbnail, get metadata, etc.)
![Page 20: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/20.jpg)
Diving Deeper: Resource Sizing
• AWS Lambda offers 23 “power levels”
• Higher levels offer more memory and more CPU power– 128 MB, lowest CPU power
– 1.5 GB, highest CPU power
• Higher power levels == lower latency for CPU-bound and bursty tasks
• Compute price scales with the power level
![Page 21: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/21.jpg)
Step 2
Mobile App
![Page 22: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/22.jpg)
Lambda Function == Mobile Backend
• AWS Lambda hosts and
scales the code
• AWS Mobile SDK on the
device
– iOS, Android/Fire, Xamarin,
Unity
• Device and user context
sent automatically
AWS LambdaMobile App
![Page 23: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/23.jpg)
What we’re going to do
1. Create an app in Android studio,
2. Using Amazon Cognito to authenticate,
3. And a simple POJO to send images and
commands to our AWS Lambda function
![Page 24: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/24.jpg)
Step 3
Build a (serverless) multi-region
deployment system
![Page 25: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/25.jpg)
AWS Lambda Regions
NEW Tokyo
launched 6/29
AWS Lambda
Region
![Page 26: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/26.jpg)
Building a single-region Auto-Deployer
Amazon S3 Bucket AWS Lambda
Lambda ZIP
Deployment
Function
![Page 27: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/27.jpg)
Building a multi-region Auto-Deployer
Amazon S3 Bucket AWS Lambda
Lambda ZIP
Deployment
Function
Amazon S3 Bucket AWS Lambda
Deployment
Function
Ireland
Tokyo
Cross-
Region
Replication
![Page 28: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/28.jpg)
What we’re going to do
1. Take a few lines of code that deploy an AWS
Lambda function from Amazon S3 to a single
region.
2. Turn it into an Amazon S3 event handler.
3. Upload our image processing microservice.
4. Turn on S3 cross-region replication.
5. Watch our function deploy automagically!
![Page 29: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/29.jpg)
Step 4
Enable Web Clients using
Amazon API Gateway
![Page 30: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/30.jpg)
Serverless Microservice Architecture
Static web content
served from
Amazon S3
AWS Lambda
+ ImageMagick
Web Client
Amazon API
Gateway
Mobile Client
![Page 31: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/31.jpg)
Amazon API Gateway
• Host multiple versions and stages of your API
• Create and distribute API keys to developers
• Throttle and monitor calls
• Cache responses
• Transform data
• Generate SDKs (including Swagger support)
![Page 32: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/32.jpg)
What we’re going to do
1. Create and populate an image processing API
2. Test it from within Amazon API Gateway
3. Deploy it
Not shown and needed for demo: CORS (see docs)
Not shown, but supported: Vanity URL
![Page 33: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/33.jpg)
Step 5
Testing
![Page 34: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/34.jpg)
AWS Lambda as a Scalable Testing Platform
HTTPS
Invoke
Function
Image
Processing
Microservice
Unit
Testing
Function
Outcome stored in
Amazon DynamoDB
![Page 35: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/35.jpg)
AWS Lambda as a Scalable Testing Platform
Load
Testing
Function
HTTPS
Invoke
Function
Image
Processing
Microservice
Unit
Testing
Function
HTTPS
Invoke
Function
Image
Processing
Microservice
Unit
Testing
Function
HTTPS
Invoke
Function
Image
Processing
Microservice
Unit
Testing
Function
HTTPS
Invoke
Function
Image
Processing
Microservice
Unit
Testing
Function
![Page 36: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/36.jpg)
What we’re going to do
1. Call our URL endpoint from within Lambda.
2. Turn this into a unit test by storing the outcome
in Amazon DynamoDB.
3. Turn this into a load test by doing it N times.
![Page 37: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/37.jpg)
Step 6
A Serverless Website
using Amazon S3
![Page 38: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/38.jpg)
What we’re going to do
1. Create a single page webapp
2. Configure S3 bucket for static website content
3. Test in a browser
![Page 39: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/39.jpg)
More Bells and Whistles
![Page 40: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/40.jpg)
Features you can add
1. Make a photo-sharing site: Add OAuth to the mobile app with Amazon Cognito user identity.
2. Add client-side analytics with Amazon Mobile Analytics.
3. Add server-side telemetry using Amazon Kinesis + Lambda.
4. Bring your own image processing libraries (native code is supported).
![Page 41: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/41.jpg)
What else can you do with AWS Lambda?
NoSQL DB
Triggers
Adding a Feature
to Amazon S3
Extending
Platforms
Scalable IoT
Backends
Real-Time
Streaming
Analysis
![Page 42: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/42.jpg)
Join the serverless revolution!
![Page 43: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/43.jpg)
Go to the AWS Lambda
console, create a function,
and run it.(The first million invokes are on us!)
![Page 44: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/44.jpg)
Congrats, you’re a
Lambda function expert!
Add an event source or
an HTTP endpoint.
![Page 45: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/45.jpg)
Build the world’s easiest
mobile backend.(Hint: Start with the built-in CRUD sample!)
![Page 46: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/46.jpg)
Follow AWS Lambda
aws.amazon.com/blogs/compute
aws.amazon.com/lambda
AWS Lambda Forum
![Page 47: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/47.jpg)
Come Meet the Team!
Mayflower
Park Hotel
405 Olive Way
WHERE
Wednesday,
August 19, 2015
5:00 - 7:00pm
WHEN
![Page 48: Microservices without the Servers: AWS Lambda in Action · Microservices without the Servers: AWS Lambda in Action ... mobile app with Amazon Cognito user identity. 2. ... Scalable](https://reader030.fdocuments.us/reader030/viewer/2022020114/5ae3c7e87f8b9ae74a8e330a/html5/thumbnails/48.jpg)