1
Cloud Made Simple with Serverless PythonSugandha AgrawalSoftware Engineer, IBM R&D, [email protected]
@SuFromIndia
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
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
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
12
When does it make sense to use Serverless?
Internet of Things
Web App Backends
Mobile Backends
Data Processing
Conversational Scenarios
Scheduled Tasks
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
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
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]
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
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
Pywren
24
http://pywren.io/
https://github.com/pywren/pywren
Pywren on Amazon Lambda:https://thenewstack.io/aws-lambda-finds-unexpected-market-scientific-computing/
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
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.