SlideShare a Scribd company logo
Serverless Apps on GCP
more dev, less ops
Joseph Lust mabl engineer @lustcoder
About Me: Joseph Lust
Engineer
■ Building the web for two decades
■ Cloud native since 2011
■ Currently building mabl ML cloud on GCP
■ Co-organizer GDG Cloud Boston Meetup
me@joelust.com
overview
■ Our serverless future
■ Serverless solutions GCP
■ Serverless demos
■ Taming serverless @ mabl
3
startups must push or perish
4
serverless just works
■ No Provisioning
■ Transparent Scaling
■ Event Driven
■ Pay only for Use
5
it’s all about opportunity cost
■ Provisioning takes time
■ Boilerplate takes time
■ You’re not running a hosting company
6
how developers deploy code
2014
2007 2013
VPS
Machine
Image
Docker
Containers
war File
AWS
Lambda
7
2000
Container Era
Serverless Era
Firebase
CF
Serverless functions
GCF
2016 2017
AF
exports.myService = (req, res) => res.send(‘hello world’);
mvf
es6+
other serverlessish GCP services
■ Serverless
▲ Scaling Clusters - Kubernetes Engine
▲ Kafka - Pub/Sub
▲ Mongo/EventSource - Firebase
▲ File Server - Cloud Storage
■ Not purely serverless, but close
▲ Tomcat/Jetty - App Engine
▲ Spark Streaming - Dataflow
9
Cloud
Pub/Sub
Cloud
Dataflow
Kubernetes
Engine
ML Engine
event driven all the way
■ Only run code on events
▲ Cloud Storage blob changes
▲ Pubsub message arrival
▲ HTTP endpoint requests
▲ DB/Auth/Conversion changes
■ No machines consuming 2% CPU all day
■ Very low latency operations
■ No more corn jobs!
10
exports.imageToJPG =
functions.storage.object().onFinalize(
async (object) => processImage()
);
example: image processor
es6+
but what do functions cost?
12
gcf is the cheapest function provider
Vendor FREE req/mo req/$
Google Cloud Functions 2M 5M
Firebase Cloud Functions 2M 2.5M
AWS Lambda 1M 5M
Azure Functions 1M 5M
13
See full details in Google Spreadsheet calculator
* Also see execution time, bandwidth, and memory costs
gcf cheapest counting free monthly allowances
14
* Also see execution time, bandwidth, and memory costs
gcf differentiators
■ Guaranteed CPU per memory allotment
■ Easy to use UI and tools
■ Stackdriver Logging & Error Reporting
Source: GCP Pricing, FB Pricing, AWS Lambda Pricing, Azure Pricing
15
Some quick demos
16
but, what about Microservices?
17
but, what about Micro Nanoservices?
18
microservices solve many pains
■ Minimize code size
▲ Can scale servers, not developers’ minds
■ Minimize deploy speed/code
■ Minimize blast radius
■ Decoupling, Coherence, Singleness of Purpose
19
how do you decouple services and handle discovery
■ We Don’t Do Discovery
■ Event Driven Queues
▲ HTTP endpoints for external services
▲ Blob change events for files
▲ Message queue events for everything else
■ No Daemons
▲ Don’t waste time spinning
20
decoupled async functions pattern
21
how do you handle changing microservice/models?
■ Versioned Payloads over the wire
▲ New service can handle older versions
■ Add Consumers, then Suppliers
■ Upgrade, don’t replace
■ Lazy read repair
▲ Pessimistic data upgrade and transform
▲ Upgrade path from old version
22
how do make slow deploys fast?
■ Multi-repo git layout
■ File change exclusion masks
■ Deploy functions in parallel
■ Harness CI & CD (e.g. Cloud Build)
23
how do you handle GCP outages?
■ Durable Pubsub subscriptions
■ No microservices on fast path
▲ Backend processing
▲ Keep the UI and lights on via Firebase
24
request costs round up
■ Requests billed per 100ms
■ Increments round up
■ Faster functions are not always cheaper
▲ 17ms → 100ms
▲ 101ms → 200ms
25
Run Time:
17ms
Billed Time: 100ms
Wasted
Time
minimizing your request costs
■ Batch multiple fast work units to fill the time (e.g. 100ms chunks)
26
Work Unit:
17ms
Billed Time: 100ms
Work Unit:
17ms
Work Unit:
17ms
Work Unit:
17ms
Work Unit:
17ms
Wasted
Time
minimizing your request costs
27
■ Use a middle man to shield file events from high memory loads
▲ Filter/light weight checks in middle man
▲ Send heavy lifting to larger function
■ Different inputs to same service have different resource needs
▲ e.g. 90% requests need 128MB ram, 10% need 512GB
▲ e.g. 80% requests complete in 30s, 20s take 2min
28
maximizing performance
■ Tune your CPU & Memory to the job
▲ Profile your microservices - CPU or memory bound?
■ More memory runs faster
▲ Greater CPU dedicated to larger memory allocation functions
▲ 128MB → 200 MHz
▲ 2048MB → 2.4GHz
▲ CPU/Memory costs increase linearly
■ Cache expensive objects between requests
▲ PubSub connections
▲ Firebase Admin instances
▲ Login tokens
29
but seriously, what’s this cost you?
30
track everything, from bits to cents
■ Metrics for every execution
▲ Every Byte of memory use
▲ Every Processor Cycle of runtime
▲ Every Byte of egress
▲ Every Invocation
■ Direct Billing to BigQuery export
▲ Easy to explore and query
▲ Easy to visualize with Data Studio
31
Real Production Numbers @ mabl
32
33
34
■ scaling to zero no longer important
■ you have a constant load
▲ Dedicated instance
when to move from Serverless to Servers
35
$
Load (rps)
Cloud Function
Dedicated
n1-standard-1
■ scaling to zero no longer important
■ you have dynamic load
▲ Kubernetes Deployment
▲ Knative function
▲ App Engine Service
when to move from Serverless to Servers
36
$
Load (rps)
Cloud FunctionKubernetes
Deployment
billing tips
■ Label functions on deploy
▲ Labels propagated to billing
▲ Can track Memory, CPU, Invocation, Ingress, Egress costs per function
■ Don’t forget the egress bandwidth
▲ Keep your data stores in the same region (Iowa)
▲ GCF only deployable to Iowa
37
gcloud beta functions deploy <your_fn> 
--labels=”app_name=<your_fn>” 
...
so, in conclusion
38
embrace serverless for
■ For low latency, event driven demands
■ For decoupled, cohesive, independent services
■ For painless deployment and auto-scaling
■ For reduced opex and oppex
39
(TL;DR) embrace serverless to
40
gcp serverless resources
■ FB CF Examples Repo: github.com/firebase/functions-samples
■ GCF Examples: github.com/GoogleCloudPlatform/nodejs-docs-samples
■ Jason Polites (great) Examples: github.com/jasonpolites/gcf-recipes
■ I/O 2018 CF Presentations
▲ Get Started Building Serverless Applications: youtu.be/JenJQ6gc14U
▲ Serverless on Google Cloud: youtu.be/iPQUdb0kssE
▲ Serverless Compute on Google Cloud: youtu.be/Y1sRy0Q2qig
▲ CI/CD in a Serverless World: youtu.be/iyGHW4UQ_Ts
▲ Building and Deploying Microservices: youtu.be/oALEthV9z_U
41
@lustcoder
Questions?

More Related Content

What's hot

The Good, Bad and Ugly of Serverless
The Good, Bad and Ugly of ServerlessThe Good, Bad and Ugly of Serverless
The Good, Bad and Ugly of Serverless
Pipedrive
 
End to-end test automation at scale
End to-end test automation at scaleEnd to-end test automation at scale
End to-end test automation at scale
mabl
 
Experiences sharing about Lambda, Kinesis, and Postgresql
Experiences sharing about Lambda, Kinesis, and PostgresqlExperiences sharing about Lambda, Kinesis, and Postgresql
Experiences sharing about Lambda, Kinesis, and Postgresql
Okis Chuang
 
Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018
☁️ Mikhail Shilkov
 
Cognos tm1 Online Training
Cognos tm1 Online TrainingCognos tm1 Online Training
Cognos tm1 Online Training
Nagendra Kumar
 
uNite 2017 - Going serverless - Gertjan Vanthienen
uNite 2017 - Going serverless - Gertjan VanthienenuNite 2017 - Going serverless - Gertjan Vanthienen
uNite 2017 - Going serverless - Gertjan Vanthienen
N Core
 
Serverless conference-labrador-at-2018
Serverless conference-labrador-at-2018Serverless conference-labrador-at-2018
Serverless conference-labrador-at-2018
Antonio Terreno
 
Cassandra On EPAM Cloud - VDAY 2017
Cassandra On EPAM Cloud - VDAY 2017Cassandra On EPAM Cloud - VDAY 2017
Cassandra On EPAM Cloud - VDAY 2017
Oresztész Margaritisz
 
Universal Serverless with AWS Fargate
Universal Serverless with AWS FargateUniversal Serverless with AWS Fargate
Universal Serverless with AWS Fargate
Eka Cahya Pratama
 
SIGGRAPH Presentation 2016 Slides
SIGGRAPH Presentation 2016 SlidesSIGGRAPH Presentation 2016 Slides
SIGGRAPH Presentation 2016 Slides
Aaron Carey
 
Serverless Architecture in Azure and AWS
Serverless Architecture in Azure and AWSServerless Architecture in Azure and AWS
Serverless Architecture in Azure and AWS
Seven Peaks Speaks
 
Using Kafka to scale database replication
Using Kafka to scale database replicationUsing Kafka to scale database replication
Using Kafka to scale database replication
Venu Ryali
 
Nextflow and AWS Batch - GCC/BOSC 2018
Nextflow and AWS Batch - GCC/BOSC 2018Nextflow and AWS Batch - GCC/BOSC 2018
Nextflow and AWS Batch - GCC/BOSC 2018
Francesco Strozzi
 
Dask for Fast Distributed Batch Scoring of Computer Vision Workloads
Dask for Fast Distributed Batch Scoring of Computer Vision WorkloadsDask for Fast Distributed Batch Scoring of Computer Vision Workloads
Dask for Fast Distributed Batch Scoring of Computer Vision Workloads
Mathew Salvaris
 
Scalable and reliable kubernetes on aws
Scalable and reliable kubernetes on awsScalable and reliable kubernetes on aws
Scalable and reliable kubernetes on aws
Applatix
 
Escalabilidade com Lambda e Elastic Beanstalk – Parte I
Escalabilidade com Lambda e Elastic Beanstalk – Parte IEscalabilidade com Lambda e Elastic Beanstalk – Parte I
Escalabilidade com Lambda e Elastic Beanstalk – Parte I
Leandro Silva
 
Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.   Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.
JavaScript Meetup HCMC
 
Neptue Graph Database - 0 to Production
Neptue Graph Database - 0 to ProductionNeptue Graph Database - 0 to Production
Neptue Graph Database - 0 to Production
israelio
 

What's hot (18)

The Good, Bad and Ugly of Serverless
The Good, Bad and Ugly of ServerlessThe Good, Bad and Ugly of Serverless
The Good, Bad and Ugly of Serverless
 
End to-end test automation at scale
End to-end test automation at scaleEnd to-end test automation at scale
End to-end test automation at scale
 
Experiences sharing about Lambda, Kinesis, and Postgresql
Experiences sharing about Lambda, Kinesis, and PostgresqlExperiences sharing about Lambda, Kinesis, and Postgresql
Experiences sharing about Lambda, Kinesis, and Postgresql
 
Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018Performance Tales of Serverless - CloudNative London 2018
Performance Tales of Serverless - CloudNative London 2018
 
Cognos tm1 Online Training
Cognos tm1 Online TrainingCognos tm1 Online Training
Cognos tm1 Online Training
 
uNite 2017 - Going serverless - Gertjan Vanthienen
uNite 2017 - Going serverless - Gertjan VanthienenuNite 2017 - Going serverless - Gertjan Vanthienen
uNite 2017 - Going serverless - Gertjan Vanthienen
 
Serverless conference-labrador-at-2018
Serverless conference-labrador-at-2018Serverless conference-labrador-at-2018
Serverless conference-labrador-at-2018
 
Cassandra On EPAM Cloud - VDAY 2017
Cassandra On EPAM Cloud - VDAY 2017Cassandra On EPAM Cloud - VDAY 2017
Cassandra On EPAM Cloud - VDAY 2017
 
Universal Serverless with AWS Fargate
Universal Serverless with AWS FargateUniversal Serverless with AWS Fargate
Universal Serverless with AWS Fargate
 
SIGGRAPH Presentation 2016 Slides
SIGGRAPH Presentation 2016 SlidesSIGGRAPH Presentation 2016 Slides
SIGGRAPH Presentation 2016 Slides
 
Serverless Architecture in Azure and AWS
Serverless Architecture in Azure and AWSServerless Architecture in Azure and AWS
Serverless Architecture in Azure and AWS
 
Using Kafka to scale database replication
Using Kafka to scale database replicationUsing Kafka to scale database replication
Using Kafka to scale database replication
 
Nextflow and AWS Batch - GCC/BOSC 2018
Nextflow and AWS Batch - GCC/BOSC 2018Nextflow and AWS Batch - GCC/BOSC 2018
Nextflow and AWS Batch - GCC/BOSC 2018
 
Dask for Fast Distributed Batch Scoring of Computer Vision Workloads
Dask for Fast Distributed Batch Scoring of Computer Vision WorkloadsDask for Fast Distributed Batch Scoring of Computer Vision Workloads
Dask for Fast Distributed Batch Scoring of Computer Vision Workloads
 
Scalable and reliable kubernetes on aws
Scalable and reliable kubernetes on awsScalable and reliable kubernetes on aws
Scalable and reliable kubernetes on aws
 
Escalabilidade com Lambda e Elastic Beanstalk – Parte I
Escalabilidade com Lambda e Elastic Beanstalk – Parte IEscalabilidade com Lambda e Elastic Beanstalk – Parte I
Escalabilidade com Lambda e Elastic Beanstalk – Parte I
 
Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.   Building workflow in Javascript: Build the awesome with Gulp.
Building workflow in Javascript: Build the awesome with Gulp.
 
Neptue Graph Database - 0 to Production
Neptue Graph Database - 0 to ProductionNeptue Graph Database - 0 to Production
Neptue Graph Database - 0 to Production
 

Similar to Serverless Apps on Google Cloud: more dev, less ops

Going Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mablGoing Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mabl
mabl
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
Joseph Lust
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
mabl
 
Firebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overviewFirebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overview
mabl
 
The Next Big Thing: Serverless
The Next Big Thing: ServerlessThe Next Big Thing: Serverless
The Next Big Thing: Serverless
Doug Vanderweide
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBM
RightScale
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
Matthias Luebken
 
Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2
kartraj
 
State of serverless
State of serverlessState of serverless
State of serverless
Anurag Saran
 
Automation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure DataAutomation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure Data
Yan Wang
 
Cloud arch patterns
Cloud arch patternsCloud arch patterns
Cloud arch patterns
Corey Huinker
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
confluent
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure Functions
Pushkar Saraf
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Dhaval Nagar
 
Why use Gitlab
Why use GitlabWhy use Gitlab
Why use Gitlab
abenyeung1
 
Why and How to Run Your Own Gitlab Runners as Your Company Grows
Why and How to Run Your Own Gitlab Runners as Your Company GrowsWhy and How to Run Your Own Gitlab Runners as Your Company Grows
Why and How to Run Your Own Gitlab Runners as Your Company Grows
NGINX, Inc.
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal HatákČtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal Haták
Ctvrtkoncz
 
Going Serverless with AWS Lambda at ReportGarden
Going Serverless with AWS Lambda at ReportGardenGoing Serverless with AWS Lambda at ReportGarden
Going Serverless with AWS Lambda at ReportGarden
Jay Gandhi
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure Functions
Marco Parenzan
 
Serverless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOpsServerless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOps
Joseph Lust
 

Similar to Serverless Apps on Google Cloud: more dev, less ops (20)

Going Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mablGoing Microserverless on Google Cloud @ mabl
Going Microserverless on Google Cloud @ mabl
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
 
Embracing Serverless with Google
Embracing Serverless with GoogleEmbracing Serverless with Google
Embracing Serverless with Google
 
Firebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overviewFirebase Cloud Functions: a quick overview
Firebase Cloud Functions: a quick overview
 
The Next Big Thing: Serverless
The Next Big Thing: ServerlessThe Next Big Thing: Serverless
The Next Big Thing: Serverless
 
Serverless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBMServerless Comparison: AWS vs Azure vs Google vs IBM
Serverless Comparison: AWS vs Azure vs Google vs IBM
 
Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
 
Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2Serverlessusecase workshop feb3_v2
Serverlessusecase workshop feb3_v2
 
State of serverless
State of serverlessState of serverless
State of serverless
 
Automation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure DataAutomation of Hadoop cluster operations in Arm Treasure Data
Automation of Hadoop cluster operations in Arm Treasure Data
 
Cloud arch patterns
Cloud arch patternsCloud arch patterns
Cloud arch patterns
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
 
Durable Azure Functions
Durable Azure FunctionsDurable Azure Functions
Durable Azure Functions
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
 
Why use Gitlab
Why use GitlabWhy use Gitlab
Why use Gitlab
 
Why and How to Run Your Own Gitlab Runners as Your Company Grows
Why and How to Run Your Own Gitlab Runners as Your Company GrowsWhy and How to Run Your Own Gitlab Runners as Your Company Grows
Why and How to Run Your Own Gitlab Runners as Your Company Grows
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal HatákČtvrtkon #64 - AWS Serverless - Michal Haták
Čtvrtkon #64 - AWS Serverless - Michal Haták
 
Going Serverless with AWS Lambda at ReportGarden
Going Serverless with AWS Lambda at ReportGardenGoing Serverless with AWS Lambda at ReportGarden
Going Serverless with AWS Lambda at ReportGarden
 
Introduction to Azure Functions
Introduction to Azure FunctionsIntroduction to Azure Functions
Introduction to Azure Functions
 
Serverless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOpsServerless Preview Environments @ Boston DevOps
Serverless Preview Environments @ Boston DevOps
 

Recently uploaded

Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 

Recently uploaded (20)

Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 

Serverless Apps on Google Cloud: more dev, less ops

  • 1. Serverless Apps on GCP more dev, less ops Joseph Lust mabl engineer @lustcoder
  • 2. About Me: Joseph Lust Engineer ■ Building the web for two decades ■ Cloud native since 2011 ■ Currently building mabl ML cloud on GCP ■ Co-organizer GDG Cloud Boston Meetup me@joelust.com
  • 3. overview ■ Our serverless future ■ Serverless solutions GCP ■ Serverless demos ■ Taming serverless @ mabl 3
  • 4. startups must push or perish 4
  • 5. serverless just works ■ No Provisioning ■ Transparent Scaling ■ Event Driven ■ Pay only for Use 5
  • 6. it’s all about opportunity cost ■ Provisioning takes time ■ Boilerplate takes time ■ You’re not running a hosting company 6
  • 7. how developers deploy code 2014 2007 2013 VPS Machine Image Docker Containers war File AWS Lambda 7 2000 Container Era Serverless Era Firebase CF Serverless functions GCF 2016 2017 AF
  • 8. exports.myService = (req, res) => res.send(‘hello world’); mvf es6+
  • 9. other serverlessish GCP services ■ Serverless ▲ Scaling Clusters - Kubernetes Engine ▲ Kafka - Pub/Sub ▲ Mongo/EventSource - Firebase ▲ File Server - Cloud Storage ■ Not purely serverless, but close ▲ Tomcat/Jetty - App Engine ▲ Spark Streaming - Dataflow 9 Cloud Pub/Sub Cloud Dataflow Kubernetes Engine ML Engine
  • 10. event driven all the way ■ Only run code on events ▲ Cloud Storage blob changes ▲ Pubsub message arrival ▲ HTTP endpoint requests ▲ DB/Auth/Conversion changes ■ No machines consuming 2% CPU all day ■ Very low latency operations ■ No more corn jobs! 10
  • 11. exports.imageToJPG = functions.storage.object().onFinalize( async (object) => processImage() ); example: image processor es6+
  • 12. but what do functions cost? 12
  • 13. gcf is the cheapest function provider Vendor FREE req/mo req/$ Google Cloud Functions 2M 5M Firebase Cloud Functions 2M 2.5M AWS Lambda 1M 5M Azure Functions 1M 5M 13 See full details in Google Spreadsheet calculator * Also see execution time, bandwidth, and memory costs
  • 14. gcf cheapest counting free monthly allowances 14 * Also see execution time, bandwidth, and memory costs
  • 15. gcf differentiators ■ Guaranteed CPU per memory allotment ■ Easy to use UI and tools ■ Stackdriver Logging & Error Reporting Source: GCP Pricing, FB Pricing, AWS Lambda Pricing, Azure Pricing 15
  • 17. but, what about Microservices? 17
  • 18. but, what about Micro Nanoservices? 18
  • 19. microservices solve many pains ■ Minimize code size ▲ Can scale servers, not developers’ minds ■ Minimize deploy speed/code ■ Minimize blast radius ■ Decoupling, Coherence, Singleness of Purpose 19
  • 20. how do you decouple services and handle discovery ■ We Don’t Do Discovery ■ Event Driven Queues ▲ HTTP endpoints for external services ▲ Blob change events for files ▲ Message queue events for everything else ■ No Daemons ▲ Don’t waste time spinning 20
  • 22. how do you handle changing microservice/models? ■ Versioned Payloads over the wire ▲ New service can handle older versions ■ Add Consumers, then Suppliers ■ Upgrade, don’t replace ■ Lazy read repair ▲ Pessimistic data upgrade and transform ▲ Upgrade path from old version 22
  • 23. how do make slow deploys fast? ■ Multi-repo git layout ■ File change exclusion masks ■ Deploy functions in parallel ■ Harness CI & CD (e.g. Cloud Build) 23
  • 24. how do you handle GCP outages? ■ Durable Pubsub subscriptions ■ No microservices on fast path ▲ Backend processing ▲ Keep the UI and lights on via Firebase 24
  • 25. request costs round up ■ Requests billed per 100ms ■ Increments round up ■ Faster functions are not always cheaper ▲ 17ms → 100ms ▲ 101ms → 200ms 25 Run Time: 17ms Billed Time: 100ms Wasted Time
  • 26. minimizing your request costs ■ Batch multiple fast work units to fill the time (e.g. 100ms chunks) 26 Work Unit: 17ms Billed Time: 100ms Work Unit: 17ms Work Unit: 17ms Work Unit: 17ms Work Unit: 17ms Wasted Time
  • 27. minimizing your request costs 27 ■ Use a middle man to shield file events from high memory loads ▲ Filter/light weight checks in middle man ▲ Send heavy lifting to larger function ■ Different inputs to same service have different resource needs ▲ e.g. 90% requests need 128MB ram, 10% need 512GB ▲ e.g. 80% requests complete in 30s, 20s take 2min
  • 28. 28
  • 29. maximizing performance ■ Tune your CPU & Memory to the job ▲ Profile your microservices - CPU or memory bound? ■ More memory runs faster ▲ Greater CPU dedicated to larger memory allocation functions ▲ 128MB → 200 MHz ▲ 2048MB → 2.4GHz ▲ CPU/Memory costs increase linearly ■ Cache expensive objects between requests ▲ PubSub connections ▲ Firebase Admin instances ▲ Login tokens 29
  • 30. but seriously, what’s this cost you? 30
  • 31. track everything, from bits to cents ■ Metrics for every execution ▲ Every Byte of memory use ▲ Every Processor Cycle of runtime ▲ Every Byte of egress ▲ Every Invocation ■ Direct Billing to BigQuery export ▲ Easy to explore and query ▲ Easy to visualize with Data Studio 31
  • 33. 33
  • 34. 34
  • 35. ■ scaling to zero no longer important ■ you have a constant load ▲ Dedicated instance when to move from Serverless to Servers 35 $ Load (rps) Cloud Function Dedicated n1-standard-1
  • 36. ■ scaling to zero no longer important ■ you have dynamic load ▲ Kubernetes Deployment ▲ Knative function ▲ App Engine Service when to move from Serverless to Servers 36 $ Load (rps) Cloud FunctionKubernetes Deployment
  • 37. billing tips ■ Label functions on deploy ▲ Labels propagated to billing ▲ Can track Memory, CPU, Invocation, Ingress, Egress costs per function ■ Don’t forget the egress bandwidth ▲ Keep your data stores in the same region (Iowa) ▲ GCF only deployable to Iowa 37 gcloud beta functions deploy <your_fn> --labels=”app_name=<your_fn>” ...
  • 39. embrace serverless for ■ For low latency, event driven demands ■ For decoupled, cohesive, independent services ■ For painless deployment and auto-scaling ■ For reduced opex and oppex 39
  • 41. gcp serverless resources ■ FB CF Examples Repo: github.com/firebase/functions-samples ■ GCF Examples: github.com/GoogleCloudPlatform/nodejs-docs-samples ■ Jason Polites (great) Examples: github.com/jasonpolites/gcf-recipes ■ I/O 2018 CF Presentations ▲ Get Started Building Serverless Applications: youtu.be/JenJQ6gc14U ▲ Serverless on Google Cloud: youtu.be/iPQUdb0kssE ▲ Serverless Compute on Google Cloud: youtu.be/Y1sRy0Q2qig ▲ CI/CD in a Serverless World: youtu.be/iyGHW4UQ_Ts ▲ Building and Deploying Microservices: youtu.be/oALEthV9z_U 41 @lustcoder