serverless / faas / lambda and how it relates to microservices
TRANSCRIPT
![Page 1: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/1.jpg)
munz & more
Serverless Architectures & Function as a Service (FaaS) OUGN / March 2017 Dr. Frank Munz
![Page 2: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/2.jpg)
2
Frank Munz
• Founded munz & more in 2007
• 17 years Oracle Middleware,Cloud, and Distributed Computing
• Consulting and High-End Training
• Wrote two Oracle WLS andone Cloud book
![Page 3: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/3.jpg)
Announced by Oracle #OOW2016
![Page 4: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/4.jpg)
Serverless& FaaS
![Page 5: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/5.jpg)
Cloud Computing:
munz & more #5
![Page 6: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/6.jpg)
![Page 7: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/7.jpg)
![Page 8: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/8.jpg)
FaaS / Serverless
Architectures?
munz & more #8
![Page 9: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/9.jpg)
munz & more #9
CloudComputingConcepts
![Page 10: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/10.jpg)
Our IT is an API
A. Cockroft / Netflix
![Page 11: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/11.jpg)
Internet Gateway
Docker Cluster
Computers
Firewall
Access Management
![Page 12: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/12.jpg)
AWS Console: Services
munz & more #12
![Page 13: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/13.jpg)
AWS CLI
munz & more #13
$ aws ec2 describe-regions --output table
![Page 14: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/14.jpg)
SDKs
munz & more #14
Language
bindings
![Page 15: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/15.jpg)
API
munz & more #15
![Page 16: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/16.jpg)
True Elasticity
16
![Page 17: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/17.jpg)
Pay Per Use
You own a massively parallel supercomputer.
Cloud Computing: Use it!
![Page 18: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/18.jpg)
Cloud Computing
API Elasticity Payperuse
FullyProgrammableDataCenter
![Page 19: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/19.jpg)
PaaS
IaaS
FaaS
AmazonEC2OracleBareMetal
AWSBeanstalkOracleACCS
AWSLambdaAzure Functions
GoogleCloudFunctionsOracleTBD
Zeroconfiguration,automaticelasticity.
Truepayperuse.
LaunchConfiguration+Autoscaling Groups
+ScalingEventspay/h/server
Min/Max,AZ,trigger,cooldownperiod
IaaSpricing
API✅Elasticity?
Payperuse?
![Page 20: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/20.jpg)
Serverless
![Page 21: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/21.jpg)
“Serverless” Example
munz & more #21
• S3 = Simple Storage Serviceaka blob storage
• put (key, value)can be (filename, file)
• Offers REST interface
(live?) example: put 2 files to the cloud
![Page 22: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/22.jpg)
S3
munz & more #22
or
http://fmtestweb.s3-website.eu-central-1.amazonaws.com/
#python/boto 3s3.Object('fmtestweb','index.html').put(…)
![Page 23: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/23.jpg)
Serverless Example: S3
munz & more #23
What you get:• Up to 5 TB per object• 14 worldwide regions
(region -> parameter in an API)• 3x replication to 3 different
availability zones (=DC) in a region• Availability 99.99%• Durability 99.999999999% (eleven 9s)
![Page 24: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/24.jpg)
Serverless Example: S3
munz & more #24
Replicatedto3availabilityzones(=DC)
Availability99.99%Durability99.999999999% (eleven9s)
14worldwideregionsregion->APIparameter
![Page 25: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/25.jpg)
The Outage March 2017
munz & more #25
![Page 26: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/26.jpg)
Serverless Example: S3
munz & more #26
• Never provision storage or a DB
• Off instance service = NO virtual server-> serverless
• NO web server
• Resource planning?-> Not for provisioning-> Cost prediction
![Page 27: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/27.jpg)
Serverless Example: S3
munz & more #27
Werner Vogel’s blog is on S3: http://www.allthingsdistributed.com/
Pricing:– Free 5GB for 1 year anyway.
– $0.0245 per GB + $0.0054 per 1,000 requests
![Page 28: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/28.jpg)
S3 is to dataas FaaS is to code
munz & more #28
![Page 29: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/29.jpg)
FaaS
![Page 30: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/30.jpg)
FaaS: Key Characteristics
• Run a function, not servers, not runtime env-> Function as a Service (FaaS)
• Stateless • Triggered by events• Continuous, automated elasticity• True pay per use
munz & more #30
![Page 31: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/31.jpg)
FaaS ImplementationsAmazon Google Microsoft Oracle
Name Lambda CloudFunctions AzureFunctions ?
Year 2014 2016 2016 2016
Status prod alpha beta announced
LanguageSupport
NodeJS 4.3.2,Java8,Python2.7, .Net1.0.1C#,nativeLinux
NodeJS JS,PHP, C#,F#,Python,bash,PowerShell
?
Remarks DeployfromgithuborBitBucket,CLI
Bundle functions,OneDriveandBotServiceintegration
Linked toEventHubCS?
Link https://aws.amazon.com/lambda/
https://azure.microsoft.com/en-us/services/functions/
https://azure.microsoft.com/en-us/services/functions/
https://cloud.oracle.com/home
![Page 32: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/32.jpg)
Edit Code Inline / Upload
munz & more #32
npm node-lambda package for locally running and remotely deploying your node.js
event: event passed to functioncontext: runtime contextcallback: optional return
(or null)
![Page 33: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/33.jpg)
Lambda Tech Details
• Event based with retry + dead letter Q
• Metering in 100 ms
• Chose the memory -> compute power
• Running in containers (not Docker)
• You can use threads and spawn processes
• You can use environment variables
munz & more #33
![Page 34: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/34.jpg)
Lambda: Limits per Function
munz & more #34
![Page 35: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/35.jpg)
Events to Trigger Functions
munz & more #35
EventsfromCloudService- API-Gateway- S3- SNS- Kinesis- Cognito- CloudFormation- CloudWatch
log/events/scheduled- CodeCommit- AppsusingAWSSDK
λVendorlock-in?
alsomultiplesources
![Page 36: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/36.jpg)
Create Lambda
munz & more #36
![Page 37: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/37.jpg)
Example 1: Simple Scenario
munz & more #37
![Page 38: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/38.jpg)
Select Blueprint
munz & more #38
![Page 39: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/39.jpg)
Test Code
munz & more #39
1
2
34
![Page 40: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/40.jpg)
Example 2: API-Gateway
Design and expose API to consumer, including
• Can trigger Lambda• Authentication• Traffic management• Import Swagger definitions• Create JavaScript, Android, iOS SDKs• XML to REST conversion• Uses Cloud Front (CDN) internally
Pricing: #calls + outbound traffic (+cache)
munz & more #40
![Page 41: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/41.jpg)
Image Recognition with Lambda
munz & more #41
https://github.com/awslabs/lambda-refarch-imagerecognition
![Page 42: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/42.jpg)
Example 3:Image Recognition
42
![Page 43: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/43.jpg)
Pay Per Use
Every started request is charged:
• First 1 million req/month are free+ 400,000 GB-seconds of compute time
• Only AWS resource where free tier is free forever.
• Pricing:$0.20 per 1 million req+ $0.00001667 per GBs
munz & more #43
![Page 44: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/44.jpg)
Security
![Page 45: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/45.jpg)
Security
• Not discussed here: Are Clouds Safe?
• Container lifetime -> request = often milli-seconds
• No open ports
• You cannot call Lambdas directly:triggered by events, e.g API-GW or SDK
“Exploit video” by CCC: “Gone in 60ms”
munz & more #45
![Page 46: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/46.jpg)
munz & more #46
https://www.youtube.com/watch?v=YZ058hmLuv0
![Page 47: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/47.jpg)
Microservices
![Page 48: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/48.jpg)
Microservices
Developing a single application as
• a suite of small services• each running in its own process / owns it‘s data• communicating with lightweight mechanisms
(M. Fowler / J. Lewis)
https://martinfowler.com/articles/microservices.html
![Page 49: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/49.jpg)
FaaS = Microservice?
What are other options?
munz & more #49
![Page 50: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/50.jpg)
FaaS vs. K8s Microservices
FaaS fulfills M. Fowler’s microservices definition
munz & more #50
AWS Lambda compared to Docker with Kubernetes
✅
BenefitsofFaaS- serverless- zeroconfig autoscaling- truepayperuse
->higherabstraction
LimitsofFaaS- language/frameworkchoice- resourcelimits- executiontime/size- vendorlock-in->reducedflexibility
![Page 51: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/51.jpg)
munz & more #51
Is𝛌 thenewμ ?
![Page 52: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/52.jpg)
Software
![Page 53: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/53.jpg)
Serverless Framework
Why a framework if your code runs in a “frame”?
• Repeating patterns: IAM, API-GW, S3 bucket etc
• NodeJS, Python, Java
• AWS and Azure
• Generates, deploys, runs Lambda in 3 LOCbased on generated YAML + .py file
munz & more #53https://serverless.com/
![Page 54: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/54.jpg)
Serverless Framework
munz & more #54
![Page 55: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/55.jpg)
AWS Greengrass
Lambda in embedded devices
• Linux 4.4+
• Locally execute Lambda triggered by local event
• Greengrass Core + IoT SDK
munz & more #55
![Page 56: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/56.jpg)
Hardware
![Page 57: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/57.jpg)
- 100TBStorage,256bitTPM- 3x10GB/sNICs- Clusterupto5,
99.999%datadurability- iSCSI,Ethernet,SIMCard- LambdainPython:Greengrass- S3PUT->Lambda- Lambdafunctions
->publicAPI,e.g.AWS- E-InkShippinglabelthatupdates- $300/10days
Snowball Edge (FaaS in a Box):
![Page 58: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/58.jpg)
“Today’s tech entrepreneurs would be out of their minds to build out their own data centers rather than renting capacity from Amazon or another low-cost provider.”
![Page 59: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/59.jpg)
www.munzandmore.com/blog
facebook.com/cloudcomputingbookfacebook.com/weblogicbook
@frankmunz
youtube.com/weblogicbook-> more than 50 web casts
Don’t be
shy J
![Page 60: Serverless / FaaS / Lambda and how it relates to Microservices](https://reader034.vdocument.in/reader034/viewer/2022042723/58e4f2301a28ab87378b6581/html5/thumbnails/60.jpg)
TL;DR #serverless / #FaaSServerless ∋ FaaS / all major clouds / event driven /stateless / true pay per use /automatic scalability /integrates with other services / cross-cloud frameworksemerge / 𝛌 could be the new µ.
@frankmunz