SlideShare uma empresa Scribd logo
1 de 53
Serverless CPH
15-04-18
Deploying machine learning in
production without servers
Damien Cavaillès
@TheDamfr
Serverless CPH
15-04-18
About
We built a 10K MAU WebApp using Firebase, some Javascript and as less
servers as possible.
Why ?
How ?
What are the anti-patterns ? Good surprises ?
Serverless CPH
15-04-18
App’s "Business" Case
Serverless CPH
15-04-18
What is the app about ?
8000+ Content pages
Companies, jobs, landing pages : developer’s "god mode" on job market to find a company he will loves to work at
Serverless CPH
15-04-18
Dev likes companies he would like to work at
App is learning what companies you like
and predict companies you will like
You can also use a search engine,
a map and some editorial content
to find companies
1
Serverless CPH
15-04-18
When ready, a developer a can fill a profile
Developer's profiles are anonymous
and confidentials
It's a safe place where a developer can
explain her career path, what she has
learned and built.
But also what are her expectations
about is future positions.
2
Serverless CPH
15-04-18
Conversations with real people working at thoses companies
Conversations are real time and can
support multiple agents
You get one-click link by SMS, mobile
layout is available and the green dot shows
who is online
3
Serverless CPH
15-04-18
250 Hires in 2018 !
Mostly in France and with French companies
more great things to come
Serverless CPH
15-04-18
Context
Serverless CPH
15-04-18
We founded the company as two developers
Content, users,
marketing, sales,
operations
More SaaS less work
We wanted to spend time
with users and ship features
on a daily basis.
Not spend hours
maintaining a large app and
systems we have built
ourselves.
It's okay to have vendor-
locking (tight coupling)
and more expensives
services if it reduces the
human time needed at
operation.
Serverless CPH
15-04-18
From idea to production in a day
● Developer’s journey…
Talk with a customer over livechat in morning
Build a PoC during day
● Deploy in production and give feedback to user
● Go Home !
Whether there is 2 or 20 of us
Serverless CPH
15-04-18
Search
First production app
Web
Process
Worker
Processes
Jobbing
Serverless CPH
15-04-18
What was key ?
Services we relied
on early
ElasticSearch
Allowed us to provide a good search experience thanks to
SearchKit. Bonsai provided a free shared instance to startup.
At launch we only had one index and 20 documents.
Firebase
Allowed us to quickly setup authentication and be realtime at
day0.
Users testified : "this looks like MeteorJS"
Redux was key to solve the callback spaghetti
Clever Cloud
Does more than Hosting
It also operate continuous integration by building and deploying
every commit on Github's master. #WebpackInTheCloud
Serverless CPH
15-04-18
What was hell ?
Requiring
monitoring and fixing
Redis
Redis instance as too many clients.
Provided Redis instance is now too small. Migration to a larger
one is required
Node Worker Processes
Redis instance refused connection, process is stalled.
Process crashed, PM2 rebooted.
Flashlight was crashed, updates has not been pushed to
ElasticSearch
COMMAND Jobbing over HTTP
Client create jobs via an express API.
Consistency hell : "Didn't got an HTTP reply, should I resend ?"
Authentication hell : "Okay got your request, need to check your
credential"
XHR
Serverless CPH
15-04-18
How is Firebase Working
Large JSON
Tree
Websocket
Listen for a node in the tree
Ref : root/ref/is/a/path
Downstream updates
Path : root/ref/is/a/path
Event : updated/created/deleted
Serverless CPH
15-04-18
How is Firebase Working
Also Functions SDK provide authentication out of the box
Triggers
Node Updated
Node created
Node Deleted
User registerd
User deleted
…
Serverless CPH
15-04-18
The first Cloud Function
That was easy to deploy ! From scratch tooks 2h on a saturday
Serverless CPH
15-04-18
"That job is broken"
Rewrote it as a Firebase Cloud Function
Easier and faster to deploy than fix production server
Serverless CPH
15-04-18
Hey Firebase Functions are still Beta
Okay !
They are going to fail.
Make sure our system is resilient enough.
Serverless CPH
15-04-18
There is no more jobs useful
Shutting down redis
Shutting down PM2 and worker process on node app
Removing API endpoints on express server
Few month later...
Serverless CPH
15-04-18
New services !
New Kids On The
Block
Algolia : Search as a Service
"Hey ! I tried Algolia and reproduced our Elastic Search setup in
a 4h"
Shutting down Elastic Search and Bonsai
Sendgrid : Transactional Emails
Templates using a Wysiwyg.
Locked-in for the best. Nobody likes to code emails anyway.
Twilio for SMS
"Wouldn't be great to send a transactionnal SMS at this moment
?
Let me try Twilio ? … `firebase deploy`...
Done, works great "
""
Serverless CPH
15-04-18
Search
New Service Map
Serverless CPH
15-04-18
Machine Learning Usecase
● From Local to Functions
Serverless CPH
15-04-18
What are we looking to predict ?
a Developer
a Company
a Company
a Company
a Company
[
…
Prediction :
=>
Serverless CPH
15-04-18
This kind of algorithm are known as :
Association Rules Mining
What are we looking to predict ?
Serverless CPH
15-04-18
Association Rules Mining
What are we looking to predict ?
Serverless CPH
15-04-18
How to
implement ?
Train LSTM with Watson 0,50€ / 1000 predictions
Training : $0.50/h
Train LSTM with Tensorflow
Easy to deploy on Google Cloud AI
But, at the time, only in python
Implement FP Growth in Node
Run it as a Cloud Function
It took me two weeks to get
access to documentation.
Training : $0.49/h
Batch Prediction :
$0.09262/h
Online Predictions :
$0.3/h
Compute time :
$0,1/h
Serverless CPH
15-04-18
Building the tree
Machine Learning + In-production learning
Pre-flight Checklist
1. 1. Preprocess (SPSS, Node, Python)
2. Train a model
3. Produce a batch of predictions
4. Control and report training
2. On the fly : Predict
Serverless CPH
15-04-18
FP Growth in detail
Building this locally
1. Preprocess => Node Script => Transactions as JSON
2. Train a model => Node Script => FPtree as JSON
3. Produce a batch of predictions => Node Script => JSON
4. Control and report training => Node Script => Console output
On the fly : Predict => Traverse FPTree with a Node Script =>
Console Output
Serverless CPH
15-04-18
FP Growth in detail
Serverless CPH
15-04-18
FP Growth in detail
Serverless CPH
15-04-18
Function-based FPGrowth Training
Training
Function
Fetch all likes
Preprocess
Make tree
Store Tree
Batch
Predictions Store Predictions
Control
Store Distribution
Remote Cron Trigger
Distribution
update
Trigger
Reporting
email
Boostrap
DataStore Bootstrap
Serverless CPH
15-04-18
Function-based On the fly prediction
On the fly
function
Fetch Tree
Traverse Tree
Store Predictions
Like written trigger
Update Client
Serverless CPH
15-04-18
Function-based On the fly prediction
Démo (not live)
Serverless CPH
15-04-18
Performance ?
Execution time : 30 sec by call
Memory : 800Mo on average
0,02$ a day – 144 000 prediction a day
Serverless CPH
15-04-18
Back to the Big Picture
Serverless CPH
15-04-18
Some Scale
numbers
Firebase functions
400K invocation by month
98 Functions in production
Longest 25min on HTTP Trigger
Firebase Realtime Database
60 Gb Bandwidth / Month
Max simultaneous connection : 450
Algolia
18,547 Records
9,805 Queries over 24h - 90% Under 3 ms
570+ Indexes
Cost 60$ / Month
Still free tier
Cost 35$ / Month
Serverless CPH
15-04-18
Some Scale
numbers
Sendgrid
1 Dedicated IP
30K email a month
Twilio
400 SMS a week (peak)
400 SMS a month (average)
Clever Cloud
1 XS instance + auto scalability
+ 4 apps & 9 addons for marketing mainly
Cost 50$ / Month
Cost App : 12€ / Month | Overall 37€
Cost 80$ / Month
Serverless CPH
15-04-18
Think bigger picture
There is many other "Organisational" services
Serverless CPH
15-04-18
Staging ?
Every service should have a staging version you can test a
staging function against
Serverless CPH
15-04-18
Learnings : Do and Don’t
● Patterns and Anti-patterns we have seen in production
Serverless CPH
15-04-18
Do : Use HTTP Triggers with an external Cron Service
We are using SetCronJob.com
Warning : Optimization !
This data fetch used to consume 6Gb of
bandwidth every day
Once optimized it wasn’t significant anymore
(need an .indexOn in database rules)
Firebase SDK will show a warning in logs
Firebase CLI offers an handy profiler
1
Serverless CPH
15-04-18
The Cold Start is going to give you a very bad experience !
Better run a Express server somewhere on a PaaS.
2
Don’t : Use HTTP Triggers as a WebServer
Serverless CPH
15-04-18
Hard to reproduce and debug
Easy to have side effects
Check events and data before executing the core of the function
3
Don’t : Triggers Cloud Functions recursively
Serverless CPH
15-04-18
If you can reproduce each jobs it’s okay.
Make sure the writing of the job is not triggering an other functions
Pub/Sub is also a good option
4
Do : Use Firebase RDB as a Queue
Serverless CPH
15-04-18
It’s easier to manage side effects if it’s all contained in one function
5
Don’t : Two functions aren’t better than one
Serverless CPH
15-04-18
Do : Realtime feedback in a function
It’s easy to push an update to firebase
6
Acknowledge : ”received”
Fetch data from external
Parse data
Persist “pushing”
Done
Serverless CPH
15-04-18
Do : Have an Express process listen to Firebase DB
Very efficient for response time
(No need to query a SGBD)
Need to be carefull about process
memory
Pretty convenient for Server Side
Rendering
Warning : React ServerSide rendering
mean you are going to
Babel/Webpack your server
7
Serverless CPH
15-04-18
Don’t : Create Race Condition
For concurrency purpose :
Functions can be executed multiple
time in the same runtime or in the
same container (you shouldn't rely on
it).
Because of cold start and resource
sharing, concurrent functions can
show race condition
If you have to :
Look for Transactions on RDB
8
Serverless CPH
15-04-18
Do : Use RDB for Uncoupling & Function as Couplers
Get out of the Client/Server logic : Stripe Checkout use case
9
listen CustomerId
write customerId:tbd
No
CustomerId
Write Trigger Function
(hold Stripe
SK)
Fetch
write
customerId
Render
Get Payment
Source write Source
Confirmation Write Request
Subscription
Function
(hold Stripe
SK)
Write Trigger Create
Sub
write
currentPlan
Render
Serverless CPH
15-04-18
Do : Functions are great for ETL
Multiposting Usecase : Extract / Load / Transform
10
Extract (Parse) Transform
Extract and Transform
Load
Load
Trigger
Email
Email
Email
Load
Serverless CPH
15-04-18
Do and Don’t : Summary
1. Do : Use HTTP Triggers with an external Cron Service
2. Don’t : Use HTTP Triggers as Express servers
3. Don’t : Triggers Cloud Functions in a recursive way
4. Do : Use Firebase RDB as a Queue
5. Don’t : Two functions aren’t better than one
6. Do : Realtime feedback in a function
7. Do : Have an Express process listen to Firebase DB
8. Don’t : Create Race Condition
9. Do : Use RDB for Uncoupling & Function as Couplers
10. Do : Use Functions as ETL
Serverless CPH
15-04-18
Glad to help you further !
Damien Cavaillès
@TheDamfr
damien@welovedevs.com

Mais conteúdo relacionado

Mais procurados

FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...Vadym Kazulkin
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherSashko Stubailo
 
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20CodeValue
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorJon Wong
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realAkamai Developers & Admins
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architectureSashko Stubailo
 
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonAdopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonVadym Kazulkin
 
Writing less code with Serverless on AWS at OOP 2022
Writing less code with Serverless on AWS at OOP 2022Writing less code with Serverless on AWS at OOP 2022
Writing less code with Serverless on AWS at OOP 2022Vadym Kazulkin
 
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at StripeSashko Stubailo
 
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...Vadym Kazulkin
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production BoostVMware Tanzu
 
Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?varien
 
Yannis Zarkadas. Enterprise data science workflows on kubeflow
Yannis Zarkadas. Enterprise data science workflows on kubeflowYannis Zarkadas. Enterprise data science workflows on kubeflow
Yannis Zarkadas. Enterprise data science workflows on kubeflowMarynaHoldaieva
 
Real User Measurement Insights, London WebPerf 2018-Nov-06
Real User Measurement Insights, London WebPerf 2018-Nov-06Real User Measurement Insights, London WebPerf 2018-Nov-06
Real User Measurement Insights, London WebPerf 2018-Nov-06Paul Calvano
 
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...Paul Calvano
 
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...Vadym Kazulkin
 
Building Faster With Your Team's UI Kit
Building Faster With Your Team's UI KitBuilding Faster With Your Team's UI Kit
Building Faster With Your Team's UI KitAtlassian
 

Mais procurados (20)

FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
 
GraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits togetherGraphQL across the stack: How everything fits together
GraphQL across the stack: How everything fits together
 
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
 
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/MeteorWhy UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
Why UI Developers Love GraphQL - Sashko Stubailo, Apollo/Meteor
 
Fluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting realFluent 2018: When third parties stop being polite... and start getting real
Fluent 2018: When third parties stop being polite... and start getting real
 
Anypoint Data Graphs
Anypoint Data GraphsAnypoint Data Graphs
Anypoint Data Graphs
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonAdopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
 
Writing less code with Serverless on AWS at OOP 2022
Writing less code with Serverless on AWS at OOP 2022Writing less code with Serverless on AWS at OOP 2022
Writing less code with Serverless on AWS at OOP 2022
 
React and GraphQL at Stripe
React and GraphQL at StripeReact and GraphQL at Stripe
React and GraphQL at Stripe
 
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
FaaS or not to FaaS. Visible and invisible benefits of the Serverless paradig...
 
Where should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and moreWhere should I run my code? Serverless, Containers, Virtual Machines and more
Where should I run my code? Serverless, Containers, Virtual Machines and more
 
Spring Boot—Production Boost
Spring Boot—Production BoostSpring Boot—Production Boost
Spring Boot—Production Boost
 
PaaS with Java
PaaS with JavaPaaS with Java
PaaS with Java
 
Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?Magento's Imagine eCommerce Conference: Do You Queue?
Magento's Imagine eCommerce Conference: Do You Queue?
 
Yannis Zarkadas. Enterprise data science workflows on kubeflow
Yannis Zarkadas. Enterprise data science workflows on kubeflowYannis Zarkadas. Enterprise data science workflows on kubeflow
Yannis Zarkadas. Enterprise data science workflows on kubeflow
 
Real User Measurement Insights, London WebPerf 2018-Nov-06
Real User Measurement Insights, London WebPerf 2018-Nov-06Real User Measurement Insights, London WebPerf 2018-Nov-06
Real User Measurement Insights, London WebPerf 2018-Nov-06
 
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...
NYC WebPerf Meetup Feb 2020 - Measuring the Adoption of Web Performance Techn...
 
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
Revolutionize DevOps with ML capabilities. Introduction to Amazon CodeGuru an...
 
Building Faster With Your Team's UI Kit
Building Faster With Your Team's UI KitBuilding Faster With Your Team's UI Kit
Building Faster With Your Team's UI Kit
 

Semelhante a Deploying Machine Learning in production without servers - #serverlessCPH

APIfying an ERP - ongoing saga
APIfying an ERP - ongoing sagaAPIfying an ERP - ongoing saga
APIfying an ERP - ongoing sagaMarjukka Niinioja
 
Proper Connections Development for Proper Domino Developers
Proper Connections Development for Proper Domino DevelopersProper Connections Development for Proper Domino Developers
Proper Connections Development for Proper Domino DevelopersMark Myers
 
2014 SharePoint Saturday Melbourne Apps or not to Apps
2014 SharePoint Saturday Melbourne Apps or not to Apps2014 SharePoint Saturday Melbourne Apps or not to Apps
2014 SharePoint Saturday Melbourne Apps or not to AppsGilles Pommier
 
Introducing the Hub for Data Orchestration
Introducing the Hub for Data OrchestrationIntroducing the Hub for Data Orchestration
Introducing the Hub for Data OrchestrationAlluxio, Inc.
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Yan Cui
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Yan Cui
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 
Why your APIs should fly first class
Why your APIs should fly first classWhy your APIs should fly first class
Why your APIs should fly first classLibbySchulze
 
PHP on Windows 2008
PHP on Windows 2008PHP on Windows 2008
PHP on Windows 2008jorke
 
Streaming in the Wild with Apache Flink
Streaming in the Wild with Apache FlinkStreaming in the Wild with Apache Flink
Streaming in the Wild with Apache FlinkKostas Tzoumas
 
Building your own calendly using amazon app sync
Building your own calendly using amazon app syncBuilding your own calendly using amazon app sync
Building your own calendly using amazon app syncDhaval Nagar
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-actionAssaf Gannon
 
Server side scalable web performance
Server side scalable web performanceServer side scalable web performance
Server side scalable web performancePer Ökvist
 
MuleSoft Surat Meetup#39 - Pragmatic API Led Connectivity
MuleSoft Surat Meetup#39 - Pragmatic API Led ConnectivityMuleSoft Surat Meetup#39 - Pragmatic API Led Connectivity
MuleSoft Surat Meetup#39 - Pragmatic API Led ConnectivityJitendra Bafna
 
Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017Jitendra Zaa
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsNicola Molinari
 
Deploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsDeploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsEddie Lau
 
Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Sid Anand
 

Semelhante a Deploying Machine Learning in production without servers - #serverlessCPH (20)

APIfying an ERP - ongoing saga
APIfying an ERP - ongoing sagaAPIfying an ERP - ongoing saga
APIfying an ERP - ongoing saga
 
Cake Php Consultant
Cake Php ConsultantCake Php Consultant
Cake Php Consultant
 
Proper Connections Development for Proper Domino Developers
Proper Connections Development for Proper Domino DevelopersProper Connections Development for Proper Domino Developers
Proper Connections Development for Proper Domino Developers
 
2014 SharePoint Saturday Melbourne Apps or not to Apps
2014 SharePoint Saturday Melbourne Apps or not to Apps2014 SharePoint Saturday Melbourne Apps or not to Apps
2014 SharePoint Saturday Melbourne Apps or not to Apps
 
Introducing the Hub for Data Orchestration
Introducing the Hub for Data OrchestrationIntroducing the Hub for Data Orchestration
Introducing the Hub for Data Orchestration
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
Why your APIs should fly first class
Why your APIs should fly first classWhy your APIs should fly first class
Why your APIs should fly first class
 
PHP on Windows 2008
PHP on Windows 2008PHP on Windows 2008
PHP on Windows 2008
 
Rest to Graphql
Rest to GraphqlRest to Graphql
Rest to Graphql
 
Streaming in the Wild with Apache Flink
Streaming in the Wild with Apache FlinkStreaming in the Wild with Apache Flink
Streaming in the Wild with Apache Flink
 
Building your own calendly using amazon app sync
Building your own calendly using amazon app syncBuilding your own calendly using amazon app sync
Building your own calendly using amazon app sync
 
Serverless in-action
Serverless in-actionServerless in-action
Serverless in-action
 
Server side scalable web performance
Server side scalable web performanceServer side scalable web performance
Server side scalable web performance
 
MuleSoft Surat Meetup#39 - Pragmatic API Led Connectivity
MuleSoft Surat Meetup#39 - Pragmatic API Led ConnectivityMuleSoft Surat Meetup#39 - Pragmatic API Led Connectivity
MuleSoft Surat Meetup#39 - Pragmatic API Led Connectivity
 
Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017Connecticut Salesforce Developer Group - Jan 2017
Connecticut Salesforce Developer Group - Jan 2017
 
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At CommercetoolsGraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
GraphQL Munich Meetup #1 - How We Use GraphQL At Commercetools
 
Deploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker ToolsDeploying Web Apps with PaaS and Docker Tools
Deploying Web Apps with PaaS and Docker Tools
 
Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)Cloud Native Data Pipelines (DataEngConf SF 2017)
Cloud Native Data Pipelines (DataEngConf SF 2017)
 

Mais de Damien Cavaillès

Mix-IT - Dev2Maker - Damien Cavaillès
Mix-IT - Dev2Maker - Damien CavaillèsMix-IT - Dev2Maker - Damien Cavaillès
Mix-IT - Dev2Maker - Damien CavaillèsDamien Cavaillès
 
BBL AXA Lille - Nearable and the Eddystone Quest
BBL AXA Lille - Nearable and the Eddystone QuestBBL AXA Lille - Nearable and the Eddystone Quest
BBL AXA Lille - Nearable and the Eddystone QuestDamien Cavaillès
 
Android Auto Talk at #DroidConFR !
Android Auto Talk at #DroidConFR !Android Auto Talk at #DroidConFR !
Android Auto Talk at #DroidConFR !Damien Cavaillès
 
Andoid Auto : Rolling Droid Gather no moss
Andoid Auto : Rolling Droid Gather no mossAndoid Auto : Rolling Droid Gather no moss
Andoid Auto : Rolling Droid Gather no mossDamien Cavaillès
 
Dev2Maker at Codeurs en Seine #Codeurs2014
Dev2Maker at Codeurs en Seine #Codeurs2014Dev2Maker at Codeurs en Seine #Codeurs2014
Dev2Maker at Codeurs en Seine #Codeurs2014Damien Cavaillès
 
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalk
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalkAndroid Wear - Ceci n'est pas une montre ! - #TakeOffTalk
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalkDamien Cavaillès
 
Presentation article rest : How-to
Presentation article rest : How-toPresentation article rest : How-to
Presentation article rest : How-toDamien Cavaillès
 

Mais de Damien Cavaillès (7)

Mix-IT - Dev2Maker - Damien Cavaillès
Mix-IT - Dev2Maker - Damien CavaillèsMix-IT - Dev2Maker - Damien Cavaillès
Mix-IT - Dev2Maker - Damien Cavaillès
 
BBL AXA Lille - Nearable and the Eddystone Quest
BBL AXA Lille - Nearable and the Eddystone QuestBBL AXA Lille - Nearable and the Eddystone Quest
BBL AXA Lille - Nearable and the Eddystone Quest
 
Android Auto Talk at #DroidConFR !
Android Auto Talk at #DroidConFR !Android Auto Talk at #DroidConFR !
Android Auto Talk at #DroidConFR !
 
Andoid Auto : Rolling Droid Gather no moss
Andoid Auto : Rolling Droid Gather no mossAndoid Auto : Rolling Droid Gather no moss
Andoid Auto : Rolling Droid Gather no moss
 
Dev2Maker at Codeurs en Seine #Codeurs2014
Dev2Maker at Codeurs en Seine #Codeurs2014Dev2Maker at Codeurs en Seine #Codeurs2014
Dev2Maker at Codeurs en Seine #Codeurs2014
 
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalk
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalkAndroid Wear - Ceci n'est pas une montre ! - #TakeOffTalk
Android Wear - Ceci n'est pas une montre ! - #TakeOffTalk
 
Presentation article rest : How-to
Presentation article rest : How-toPresentation article rest : How-to
Presentation article rest : How-to
 

Último

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 

Último (20)

New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 

Deploying Machine Learning in production without servers - #serverlessCPH

  • 1. Serverless CPH 15-04-18 Deploying machine learning in production without servers Damien Cavaillès @TheDamfr
  • 2. Serverless CPH 15-04-18 About We built a 10K MAU WebApp using Firebase, some Javascript and as less servers as possible. Why ? How ? What are the anti-patterns ? Good surprises ?
  • 4. Serverless CPH 15-04-18 What is the app about ? 8000+ Content pages Companies, jobs, landing pages : developer’s "god mode" on job market to find a company he will loves to work at
  • 5. Serverless CPH 15-04-18 Dev likes companies he would like to work at App is learning what companies you like and predict companies you will like You can also use a search engine, a map and some editorial content to find companies 1
  • 6. Serverless CPH 15-04-18 When ready, a developer a can fill a profile Developer's profiles are anonymous and confidentials It's a safe place where a developer can explain her career path, what she has learned and built. But also what are her expectations about is future positions. 2
  • 7. Serverless CPH 15-04-18 Conversations with real people working at thoses companies Conversations are real time and can support multiple agents You get one-click link by SMS, mobile layout is available and the green dot shows who is online 3
  • 8. Serverless CPH 15-04-18 250 Hires in 2018 ! Mostly in France and with French companies more great things to come
  • 10. Serverless CPH 15-04-18 We founded the company as two developers Content, users, marketing, sales, operations More SaaS less work We wanted to spend time with users and ship features on a daily basis. Not spend hours maintaining a large app and systems we have built ourselves. It's okay to have vendor- locking (tight coupling) and more expensives services if it reduces the human time needed at operation.
  • 11. Serverless CPH 15-04-18 From idea to production in a day ● Developer’s journey… Talk with a customer over livechat in morning Build a PoC during day ● Deploy in production and give feedback to user ● Go Home ! Whether there is 2 or 20 of us
  • 12. Serverless CPH 15-04-18 Search First production app Web Process Worker Processes Jobbing
  • 13. Serverless CPH 15-04-18 What was key ? Services we relied on early ElasticSearch Allowed us to provide a good search experience thanks to SearchKit. Bonsai provided a free shared instance to startup. At launch we only had one index and 20 documents. Firebase Allowed us to quickly setup authentication and be realtime at day0. Users testified : "this looks like MeteorJS" Redux was key to solve the callback spaghetti Clever Cloud Does more than Hosting It also operate continuous integration by building and deploying every commit on Github's master. #WebpackInTheCloud
  • 14. Serverless CPH 15-04-18 What was hell ? Requiring monitoring and fixing Redis Redis instance as too many clients. Provided Redis instance is now too small. Migration to a larger one is required Node Worker Processes Redis instance refused connection, process is stalled. Process crashed, PM2 rebooted. Flashlight was crashed, updates has not been pushed to ElasticSearch COMMAND Jobbing over HTTP Client create jobs via an express API. Consistency hell : "Didn't got an HTTP reply, should I resend ?" Authentication hell : "Okay got your request, need to check your credential" XHR
  • 15. Serverless CPH 15-04-18 How is Firebase Working Large JSON Tree Websocket Listen for a node in the tree Ref : root/ref/is/a/path Downstream updates Path : root/ref/is/a/path Event : updated/created/deleted
  • 16. Serverless CPH 15-04-18 How is Firebase Working Also Functions SDK provide authentication out of the box Triggers Node Updated Node created Node Deleted User registerd User deleted …
  • 17. Serverless CPH 15-04-18 The first Cloud Function That was easy to deploy ! From scratch tooks 2h on a saturday
  • 18. Serverless CPH 15-04-18 "That job is broken" Rewrote it as a Firebase Cloud Function Easier and faster to deploy than fix production server
  • 19. Serverless CPH 15-04-18 Hey Firebase Functions are still Beta Okay ! They are going to fail. Make sure our system is resilient enough.
  • 20. Serverless CPH 15-04-18 There is no more jobs useful Shutting down redis Shutting down PM2 and worker process on node app Removing API endpoints on express server Few month later...
  • 21. Serverless CPH 15-04-18 New services ! New Kids On The Block Algolia : Search as a Service "Hey ! I tried Algolia and reproduced our Elastic Search setup in a 4h" Shutting down Elastic Search and Bonsai Sendgrid : Transactional Emails Templates using a Wysiwyg. Locked-in for the best. Nobody likes to code emails anyway. Twilio for SMS "Wouldn't be great to send a transactionnal SMS at this moment ? Let me try Twilio ? … `firebase deploy`... Done, works great " ""
  • 23. Serverless CPH 15-04-18 Machine Learning Usecase ● From Local to Functions
  • 24. Serverless CPH 15-04-18 What are we looking to predict ? a Developer a Company a Company a Company a Company [ … Prediction : =>
  • 25. Serverless CPH 15-04-18 This kind of algorithm are known as : Association Rules Mining What are we looking to predict ?
  • 26. Serverless CPH 15-04-18 Association Rules Mining What are we looking to predict ?
  • 27. Serverless CPH 15-04-18 How to implement ? Train LSTM with Watson 0,50€ / 1000 predictions Training : $0.50/h Train LSTM with Tensorflow Easy to deploy on Google Cloud AI But, at the time, only in python Implement FP Growth in Node Run it as a Cloud Function It took me two weeks to get access to documentation. Training : $0.49/h Batch Prediction : $0.09262/h Online Predictions : $0.3/h Compute time : $0,1/h
  • 28. Serverless CPH 15-04-18 Building the tree Machine Learning + In-production learning Pre-flight Checklist 1. 1. Preprocess (SPSS, Node, Python) 2. Train a model 3. Produce a batch of predictions 4. Control and report training 2. On the fly : Predict
  • 29. Serverless CPH 15-04-18 FP Growth in detail Building this locally 1. Preprocess => Node Script => Transactions as JSON 2. Train a model => Node Script => FPtree as JSON 3. Produce a batch of predictions => Node Script => JSON 4. Control and report training => Node Script => Console output On the fly : Predict => Traverse FPTree with a Node Script => Console Output
  • 32. Serverless CPH 15-04-18 Function-based FPGrowth Training Training Function Fetch all likes Preprocess Make tree Store Tree Batch Predictions Store Predictions Control Store Distribution Remote Cron Trigger Distribution update Trigger Reporting email Boostrap DataStore Bootstrap
  • 33. Serverless CPH 15-04-18 Function-based On the fly prediction On the fly function Fetch Tree Traverse Tree Store Predictions Like written trigger Update Client
  • 34. Serverless CPH 15-04-18 Function-based On the fly prediction Démo (not live)
  • 35. Serverless CPH 15-04-18 Performance ? Execution time : 30 sec by call Memory : 800Mo on average 0,02$ a day – 144 000 prediction a day
  • 37. Serverless CPH 15-04-18 Some Scale numbers Firebase functions 400K invocation by month 98 Functions in production Longest 25min on HTTP Trigger Firebase Realtime Database 60 Gb Bandwidth / Month Max simultaneous connection : 450 Algolia 18,547 Records 9,805 Queries over 24h - 90% Under 3 ms 570+ Indexes Cost 60$ / Month Still free tier Cost 35$ / Month
  • 38. Serverless CPH 15-04-18 Some Scale numbers Sendgrid 1 Dedicated IP 30K email a month Twilio 400 SMS a week (peak) 400 SMS a month (average) Clever Cloud 1 XS instance + auto scalability + 4 apps & 9 addons for marketing mainly Cost 50$ / Month Cost App : 12€ / Month | Overall 37€ Cost 80$ / Month
  • 39. Serverless CPH 15-04-18 Think bigger picture There is many other "Organisational" services
  • 40. Serverless CPH 15-04-18 Staging ? Every service should have a staging version you can test a staging function against
  • 41. Serverless CPH 15-04-18 Learnings : Do and Don’t ● Patterns and Anti-patterns we have seen in production
  • 42. Serverless CPH 15-04-18 Do : Use HTTP Triggers with an external Cron Service We are using SetCronJob.com Warning : Optimization ! This data fetch used to consume 6Gb of bandwidth every day Once optimized it wasn’t significant anymore (need an .indexOn in database rules) Firebase SDK will show a warning in logs Firebase CLI offers an handy profiler 1
  • 43. Serverless CPH 15-04-18 The Cold Start is going to give you a very bad experience ! Better run a Express server somewhere on a PaaS. 2 Don’t : Use HTTP Triggers as a WebServer
  • 44. Serverless CPH 15-04-18 Hard to reproduce and debug Easy to have side effects Check events and data before executing the core of the function 3 Don’t : Triggers Cloud Functions recursively
  • 45. Serverless CPH 15-04-18 If you can reproduce each jobs it’s okay. Make sure the writing of the job is not triggering an other functions Pub/Sub is also a good option 4 Do : Use Firebase RDB as a Queue
  • 46. Serverless CPH 15-04-18 It’s easier to manage side effects if it’s all contained in one function 5 Don’t : Two functions aren’t better than one
  • 47. Serverless CPH 15-04-18 Do : Realtime feedback in a function It’s easy to push an update to firebase 6 Acknowledge : ”received” Fetch data from external Parse data Persist “pushing” Done
  • 48. Serverless CPH 15-04-18 Do : Have an Express process listen to Firebase DB Very efficient for response time (No need to query a SGBD) Need to be carefull about process memory Pretty convenient for Server Side Rendering Warning : React ServerSide rendering mean you are going to Babel/Webpack your server 7
  • 49. Serverless CPH 15-04-18 Don’t : Create Race Condition For concurrency purpose : Functions can be executed multiple time in the same runtime or in the same container (you shouldn't rely on it). Because of cold start and resource sharing, concurrent functions can show race condition If you have to : Look for Transactions on RDB 8
  • 50. Serverless CPH 15-04-18 Do : Use RDB for Uncoupling & Function as Couplers Get out of the Client/Server logic : Stripe Checkout use case 9 listen CustomerId write customerId:tbd No CustomerId Write Trigger Function (hold Stripe SK) Fetch write customerId Render Get Payment Source write Source Confirmation Write Request Subscription Function (hold Stripe SK) Write Trigger Create Sub write currentPlan Render
  • 51. Serverless CPH 15-04-18 Do : Functions are great for ETL Multiposting Usecase : Extract / Load / Transform 10 Extract (Parse) Transform Extract and Transform Load Load Trigger Email Email Email Load
  • 52. Serverless CPH 15-04-18 Do and Don’t : Summary 1. Do : Use HTTP Triggers with an external Cron Service 2. Don’t : Use HTTP Triggers as Express servers 3. Don’t : Triggers Cloud Functions in a recursive way 4. Do : Use Firebase RDB as a Queue 5. Don’t : Two functions aren’t better than one 6. Do : Realtime feedback in a function 7. Do : Have an Express process listen to Firebase DB 8. Don’t : Create Race Condition 9. Do : Use RDB for Uncoupling & Function as Couplers 10. Do : Use Functions as ETL
  • 53. Serverless CPH 15-04-18 Glad to help you further ! Damien Cavaillès @TheDamfr damien@welovedevs.com