Serverless in production, an experience report (microservices london)
Serverless / FaaS / Lambda and how it relates to Microservices
-
Upload
frank-munz -
Category
Internet
-
view
187 -
download
1
Transcript of Serverless / FaaS / Lambda and how it relates to Microservices
munz & more
Serverless Architectures & Function as a Service (FaaS) OUGN / March 2017 Dr. Frank Munz
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
Announced by Oracle #OOW2016
Serverless& FaaS
Cloud Computing:
munz & more #5
FaaS / Serverless
Architectures?
munz & more #8
munz & more #9
CloudComputingConcepts
Our IT is an API
A. Cockroft / Netflix
Internet Gateway
Docker Cluster
Computers
Firewall
Access Management
AWS Console: Services
munz & more #12
AWS CLI
munz & more #13
$ aws ec2 describe-regions --output table
SDKs
munz & more #14
Language
bindings
API
munz & more #15
True Elasticity
16
Pay Per Use
You own a massively parallel supercomputer.
Cloud Computing: Use it!
Cloud Computing
API Elasticity Payperuse
FullyProgrammableDataCenter
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?
Serverless
“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
S3
munz & more #22
or
http://fmtestweb.s3-website.eu-central-1.amazonaws.com/
#python/boto 3s3.Object('fmtestweb','index.html').put(…)
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)
Serverless Example: S3
munz & more #24
Replicatedto3availabilityzones(=DC)
Availability99.99%Durability99.999999999% (eleven9s)
14worldwideregionsregion->APIparameter
The Outage March 2017
munz & more #25
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
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
S3 is to dataas FaaS is to code
munz & more #28
FaaS
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
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
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)
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
Lambda: Limits per Function
munz & more #34
Events to Trigger Functions
munz & more #35
EventsfromCloudService- API-Gateway- S3- SNS- Kinesis- Cognito- CloudFormation- CloudWatch
log/events/scheduled- CodeCommit- AppsusingAWSSDK
λVendorlock-in?
alsomultiplesources
Create Lambda
munz & more #36
Example 1: Simple Scenario
munz & more #37
Select Blueprint
munz & more #38
Test Code
munz & more #39
1
2
34
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
Image Recognition with Lambda
munz & more #41
https://github.com/awslabs/lambda-refarch-imagerecognition
Example 3:Image Recognition
42
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
Security
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
munz & more #46
https://www.youtube.com/watch?v=YZ058hmLuv0
Microservices
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
FaaS = Microservice?
What are other options?
munz & more #49
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
munz & more #51
Is𝛌 thenewμ ?
Software
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/
Serverless Framework
munz & more #54
AWS Greengrass
Lambda in embedded devices
• Linux 4.4+
• Locally execute Lambda triggered by local event
• Greengrass Core + IoT SDK
munz & more #55
Hardware
- 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):
“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.”
www.munzandmore.com/blog
facebook.com/cloudcomputingbookfacebook.com/weblogicbook
@frankmunz
youtube.com/weblogicbook-> more than 50 web casts
Don’t be
shy J
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