building serverless machine learning models in the cloud [pydata dc]

25
clda.co/pydatadc 10/08/2016 Building Serverless Machine Learning models in the Cloud

Upload: alex-casalboni

Post on 16-Apr-2017

162 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc10/08/2016

Building  Serverless  Machine  Learning  models  

in  the  Cloud

Page 2: Building Serverless Machine Learning Models in the Cloud [PyData DC]

About  Me

@alex_casalboni

clda.co/pydata-­‐dc

Bachelor  in  Computer  Science

Master  in  Sound  &  Music  Engineering

6+  years  of  Web  Development

3+  years  of  Python

Page 3: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Have  you  ever  met  a  Data  Scien?st?

Bob

Bob  is  very  smart  and  curious

Bob  loves  Python  &  (Big)Data

Bob  builds  great  ML  models

Bob  likes  user-­‐centered  ML

Page 4: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Bob  can  build  a  model  in  ~30  LOC!

clda.co/ML-codeBob

Page 5: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

But…

Page 6: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Phase  1:  Analysis  &  Modeling

+

+

Bob

Data

Time

Page 7: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Phase  2:  Visualiza?on  &  Prototyping

+

+

Bob

Data

Time

ML  Model

Data  VisualisaKon

Prototype

+

+

Page 8: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Phase  3:  Disillusion

+

+

Bob

Data

Time

ML  Model

Data  VisualisaKon

Prototype

+

+

ProducKon  Code

Page 9: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Phase  4:  Prod-­‐ready  Integra?on

+

+

Bob

Data

Time

ML  Model

Data  VisualisaKon

Prototype

+

+

WebDev

DevOps

A  lot  of  Time

+

+

Page 10: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

The  lack  of  ownership

!=

Data  ScienKst DevOps

Mathema?cal  modeling  Sta?s?cal  analysis  

Data  mining

(Cloud)  Opera?ons  System  administra?on  So\ware  best  prac?ces

Page 11: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Why  is  deploying  ML  models  a  challenge?

Bob’s  prototypes  are’t  producKon-­‐ready

Bob  needs  ElasKcity  &  High  Availability

Bob  will  deploy  hundreds  of  models

Bobs  wants  plenty  of  features

Bob

Page 12: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Machine  Learning  as  a  Service  (MLaaS)

AmazonMachine  Learning

AzureMachine  Learning

GooglePredic?on  API

IMBWatson  Analy?cs

BigML

Page 13: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Deployment  Strategies

1.  Web-­‐app  controller

how  will  Bob  update  his  model(s)?

same  website  auth  layer?

shared  uWSGI  processes?

It’s  disarmingly  simple,  but…

Bob

Page 14: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Deployment  Strategies

2.  Fleet  of  servers

same  problems  as  before

Bob  has  many  more  machines  to  maintain

sKll  no  elasKcity  (over-­‐provisioning)

Bigger  capacity  and  no  code  changes,  but…

Load  Balancing

Bob Bob2 Bob3

Page 15: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Deployment  Strategies

<Bob>

3.  Auto  Scaling

sKll  shared  resources?  containers?

even  bigger  lack  of  ownership

what  about  caching,  versioning  and  auth?

Bob  achieved  elasKcity  and  availability  ,  but…

Load  Balancing  +  Auto  Scaling

Page 16: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Deployment  Strategies

4.  Serverless  Compu?ng

+Amazon  API  Gateway

AWS  Lambda

Happy  Bob

Managed  infrastructure  +  BYOC

Transparent  elasKcity  and  PAYG

Many  useful  features  for  free

Bob  doesn’t  need  (to  be)  a  DevOps  anymore!

Page 17: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

There is always a server somewhere, you just don't have to worry about it :)

Page 18: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Benefits  of  Serverless  Machine  Learning

Versioning,  staging  &  caching

1  model  =  1  microservice

IntuiKve  RESTful  interface

High  Availability  (no  downKme)

Very  li_le  operaKonal  effort

Transparent  elasKcity  (PAYG)

Failure  isolaKon Offline  training  phase

ProducKon-­‐ready  prototypes A/B  tesKng  through  composiKon

Page 19: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

A  simple  example:  Serverless  Sen?ment  Analysis

clda.co/ML-­‐Lambda

Page 20: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

A  real-­‐world  example

Serverless  ML  @  Cloud  Academy

MulK-­‐model  architecture

RESTful  interface  for  each  ML  model

S3  +  RDS  for  storage

Periodic  training  (offline)

Page 21: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Page 22: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Page 23: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

Limita?on  of  Serverless  ML

AWS  Lambda

No  real-­‐Kme  models  (only  pseudo  real-­‐Kme)

Deployment  package  management:  size  limit  and  OS  libraries

Not  suitable  for  model  training  yet  (5  min  max  execuKon  Kme)

Cold  start  Kme  is  long  and  hard  to  avoid

Unit/integraKon  tests  help,  but  not  enough

Page 24: Building Serverless Machine Learning Models in the Cloud [PyData DC]

clda.co/pydata-­‐dc

The  Serverless  Ecosystem

AWS  Lambda

Microsoh  Azure  FuncKons

Google  Cloud  FuncKons

IBM  Bluemix  OpenWhisk

hook.io

Cloud  Placorms Func?on  as  a  Service

iron.io

Auth0  (SSO)

Misc

Firebase  (DB)

Page 25: Building Serverless Machine Learning Models in the Cloud [PyData DC]

Thank  you!                

jobs.cloudacademy.comP.S.  we  are  hiring!