cloud made simple with serverless python€¦ · microservices: o each service is a functional...

27
1 Cloud Made Simple with Serverless Python Sugandha Agrawal Software Engineer, IBM R&D, Germany [email protected] @SuFromIndia

Upload: others

Post on 08-Oct-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

1

Cloud Made Simple with Serverless PythonSugandha AgrawalSoftware Engineer, IBM R&D, [email protected]

@SuFromIndia

Page 2: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

How do I run my codeon the cloud today?

2

</> ?

Page 3: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

3

Evolution of Serverless

Page 4: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

4

Increasing Abstraction

Functions

Application

Runtime

Operating System

Virtualization

Hardware

IaaS PaaS FaaS

Functions

Application

Runtime

Operating System

Virtualization

Hardware

Functions

Application

Runtime

Operating System

Virtualization

Hardware

Functions

Application

Runtime

Operating System

Virtualization

Hardware

On-Prem

Platform Managed

User Managed

Page 5: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

5

Writing Applications

Monolithic:o Application deployed as one unit.o Introducing new code is a complete new

deployment.Microservices:o Each service is a functional component of

your application.o DecouplingFaaSo Further decoupling – each fn does one

thing & does it well.o No infrastructure management.

Monolithic Application

Microservice

Microservice

Microservice

Function

Function

Function

Function

Function

Page 6: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

No Servers

6

Page 7: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

Scalability

7

Page 8: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

Pay per use

8

Page 9: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

Event Driven Workloads

9

Page 10: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

Integration with Cloud Services

10

Page 11: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

What does Serverless promise to developers?

Decreased time to market

11

“Serverless abstracts away the most menial parts of building an application, leaving developers free to actually spend their days coding.”

- serverless.com

Page 12: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

12

When does it make sense to use Serverless?

Internet of Things

Web App Backends

Mobile Backends

Data Processing

Conversational Scenarios

Scheduled Tasks

Page 13: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

13

Weather Gods

March, 2019 / © 2019 IBM Corporation

Page 14: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Weather Gods, Backend Architecture

14

USERS DB

GROUP SCANNER

RAIN SCANNER

1 Cron Trigger Every 3 Minutes

WEATHER CHECKER

WEATHER UPDATE

SNOW SCANNER

WIND SCANNER

STORM SCANNER

FROST SCANNER

ETC SCANNER NOTIFICATION TRIGGER

SEND NOTIFICATIONTWC

Service

IBM Cloud Push

Notifications Service

Weather Gods App

2

3

4

TRIGGER

March, 2019 / © 2019 IBM Corporation

Page 15: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Parallel Code Execution

- Run all “weather scanners” in parallel

- Scale these up and down as required based on user preferences

15

Weather Gods, Why Serverless? Scheduled Tasks

- Chronological Trigger every 3 minutes

Integrated Platform Services

- The Weather Company Data

- Cloudant NoSQL DB

- Notifications Service

Event Driven Code Execution

- User location updated

- New user in DB

- New weather item in DB

March, 2019 / © 2019 IBM Corporation

Page 16: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

I’m ready to write my next app. How do I get started with Serverless Python?

16

Page 17: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

17

Some Serverless Options

Apache OpenWhisk – Apache Incubator Project [Node.js, Go, Java, PHP, Ruby, Swift, Python]IBM Cloud Functions – managed OpenWhisk on IBM Cloud[Node.js, Go, Java, PHP, Ruby, Swift, Python]Azure Functions – Microsoft [GA: Node.js, C#, F#, Python]Amazon Lambda – Amazon [Node.js, Java, Go, C#, Python]Python Anywhere – more focused on web hosting & education[Python]

Page 18: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Write code to run in the cloud.

18

Entry Point

Parameters (json)

Response (json)

Page 19: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

19

IBM Cloud Functions & Python Demo

o “Bernese mountain dog”o “dog”o “animal”

[input] [output]

Page 20: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

20

IBM Cloud Functions & Python Demo

CLOUDANT

READ CHANGES FROM DB

GET CLASSIFIERS

New DB item

(imageUrl)

CLOUDANT CHANGES TRIGGER

VISUAL RECOGNITION

SERVICE

March, 2019 / © 2019 IBM Corporation

Page 21: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

21

Demo.New Image Trigger + Image Analysis in Python.

Page 22: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

That’s cool and all, but I’ve got bigger dreams for serverless python!

22

Page 23: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Pywren – Cloud Computing for Everyone

23

• Great for running “embarrassingly parallel” workloads.

• No effort to separate problem into parallel tasks

• No dependency & need for communication between those parallel tasks or task results.

• Simplifies many scale-out use cases for data science and computational imaging.

• Provides a simple “push to the cloud” experience

• Pywren runs the python function at scale while monitoring executions, and obtaining and combining results.

Function

Function

Function

Function

Function

Function Result

Page 24: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Pywren

24

http://pywren.io/

https://github.com/pywren/pywren

Pywren on Amazon Lambda:https://thenewstack.io/aws-lambda-finds-unexpected-market-scientific-computing/

Page 25: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

Pywren

25

http://pywren.io/

https://github.com/pywren/pywren

Pywren on IBM Cloud Functions:https://www.ibm.com/blogs/bluemix/2019/01/monte-carlo-simulations-with-ibm-cloud-functions/

March, 2019 / © 2019 IBM Corporation

Page 26: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

26

Thank you

https://cloud.ibm.com/openwhisk

twitter.com/SuFromIndia

https://github.com/SugandhaAgrawal/o

w-py

Feel free to reach out for any questions or to share what you’re working on.

Page 27: Cloud Made Simple with Serverless Python€¦ · Microservices: o Each service is a functional component of your application. o Decoupling FaaS ... building an application, leaving

27March, 2019 / © 2019 IBM Corporation