Python in The
Serverless
Era
Photo by Zack Spear
Icon by Serverless
◉ Chief Architect @
◉ Ex- :
Cloud Architect @ AutoCAD
◉ Find me at @benikbauer
I am Benny Bauer
Hello!
What is Serverless
Dev SaaS BaaS FaaS
What is FaaS - Function as a
Service
Fully-managed
compute
Provisioning,
patching, scaling,
monitoring, logging
are provided
out-of-the-box
Deploy your code
Just package and
upload the code
Pay for actual usage
Getting charged only
upon code execution,
per 100ms
100%
UTILIZATION
LESS OPS
How it works
Deploy your
code
Define
triggers
Code
execution
EVENT-DRIVEN
AUTO SCALING
+
AVAILABILITY
◉ HTTP requests
◉ Storage (e.g. file upload)
◉ DB (e.g. row insert)
◉ Scheduled tasks
◉ Messaging
◉ Many many more...
Other
- Scheduled tasks
- Distributed compute
API
- Web backend
- Mobile backend
- Bot
Use cases
Data processing
- IoT
- Streams (analytics,
logging, etc)
- Files (images, text, etc.)
Operations
- CI
- Policy enforcement
- Provisioning
Other
- Scheduled tasks
- Distributed compute
API
- Web backend
- Mobile backend
- Bot
Use cases
Data processing
- IoT
- Streams (analytics,
logging, etc)
- Files (images, text, etc.)
Operations
- CI
- Policy enforcement
- Provisioning
Things to be aware of
Stateless
Instances are ephemeral.
Store state on client-side,
cache or db.
Cold start
Latency (< 2 sec)
when container is
cold (upon first run or
inactivity).
Vendor lock-in
Integrations with other
services are the real bait.
Granularity
Unit of deployment is
nanoservice/function.
Costs
Cost-effective up to a
certain point.
Limitations
Execution time is 5 min.
Payload & disk sizes are
limited.
Let’s get to business!
Python & FaaS
Cloud providers
Python 2.7 & 3.6 are supported by:
● AWS
● OpenWhisk
● Microsoft Azure - experimental, still not GA
Configuration
- Event binding
- Resources definition
- Security roles
definition
The need for frameworks
Deployment
- Package
- Upload
- Rollback
Frameworks
Chalice
Serverless Framework
Zappa
One function only. Serves as a WSGI server
WSGI
Unique features:
● Global deployment
● “Keep warm” functionality
● SSL certification
● Support for AWS Lambda compatible python
libraries (lambda-packages & Manylinux
wheels)
Zappa
● Python Serverless Microframework for AWS
● Each endpoint is a separate function
Chalice
Chalice
$ pip install chalice
$ chalice new-project helloworld && cd helloworld
$ cat app.py
from chalice import Chalice
app = Chalice(app_name="helloworld")
@app.route("/")
def index():
return {"hello": "world"}
$ chalice deploy
Unique features:
● Automatic IAM policy generation
Chalice
Pywren
import pywren
def scrape(url):
# scrape it...
return data
wrenexec = pywren.default_executor()
futures = wrenexec.map(scrape, [url,...])
results = pywren.get_all_results(futures)
Credit: Sean Smith (https://blog.seanssmith.com/posts/pywren-web-scraping.html)Credit: Sean Smith (https://blog.seanssmith.com/posts/pywren-web-scraping.html)
Summary
What was it all about?
Takeaways
◉ Serverless is a fast & cost-effective way to
deliver many use cases with Python
◉ New frontiers for Python (frameworks, tooling,
etc.)
Any questions?
Thanks!
Slides template by SlidesCarnival
Find me at @benikbauer
This work is licensed under a CC Attribution 4.0 International License.

Python in the serverless era (PyCon 2017)

  • 1.
    Python in The Serverless Era Photoby Zack Spear Icon by Serverless
  • 2.
    ◉ Chief Architect@ ◉ Ex- : Cloud Architect @ AutoCAD ◉ Find me at @benikbauer I am Benny Bauer Hello!
  • 3.
    What is Serverless DevSaaS BaaS FaaS
  • 4.
    What is FaaS- Function as a Service Fully-managed compute Provisioning, patching, scaling, monitoring, logging are provided out-of-the-box Deploy your code Just package and upload the code Pay for actual usage Getting charged only upon code execution, per 100ms 100% UTILIZATION LESS OPS
  • 5.
    How it works Deployyour code Define triggers Code execution EVENT-DRIVEN AUTO SCALING + AVAILABILITY ◉ HTTP requests ◉ Storage (e.g. file upload) ◉ DB (e.g. row insert) ◉ Scheduled tasks ◉ Messaging ◉ Many many more...
  • 6.
    Other - Scheduled tasks -Distributed compute API - Web backend - Mobile backend - Bot Use cases Data processing - IoT - Streams (analytics, logging, etc) - Files (images, text, etc.) Operations - CI - Policy enforcement - Provisioning
  • 7.
    Other - Scheduled tasks -Distributed compute API - Web backend - Mobile backend - Bot Use cases Data processing - IoT - Streams (analytics, logging, etc) - Files (images, text, etc.) Operations - CI - Policy enforcement - Provisioning
  • 8.
    Things to beaware of Stateless Instances are ephemeral. Store state on client-side, cache or db. Cold start Latency (< 2 sec) when container is cold (upon first run or inactivity). Vendor lock-in Integrations with other services are the real bait. Granularity Unit of deployment is nanoservice/function. Costs Cost-effective up to a certain point. Limitations Execution time is 5 min. Payload & disk sizes are limited.
  • 9.
    Let’s get tobusiness! Python & FaaS
  • 10.
    Cloud providers Python 2.7& 3.6 are supported by: ● AWS ● OpenWhisk ● Microsoft Azure - experimental, still not GA
  • 11.
    Configuration - Event binding -Resources definition - Security roles definition The need for frameworks Deployment - Package - Upload - Rollback
  • 12.
  • 13.
  • 14.
    Zappa One function only.Serves as a WSGI server WSGI
  • 15.
    Unique features: ● Globaldeployment ● “Keep warm” functionality ● SSL certification ● Support for AWS Lambda compatible python libraries (lambda-packages & Manylinux wheels) Zappa
  • 16.
    ● Python ServerlessMicroframework for AWS ● Each endpoint is a separate function Chalice
  • 17.
    Chalice $ pip installchalice $ chalice new-project helloworld && cd helloworld $ cat app.py from chalice import Chalice app = Chalice(app_name="helloworld") @app.route("/") def index(): return {"hello": "world"} $ chalice deploy
  • 18.
    Unique features: ● AutomaticIAM policy generation Chalice
  • 19.
  • 20.
    import pywren def scrape(url): #scrape it... return data wrenexec = pywren.default_executor() futures = wrenexec.map(scrape, [url,...]) results = pywren.get_all_results(futures) Credit: Sean Smith (https://blog.seanssmith.com/posts/pywren-web-scraping.html)Credit: Sean Smith (https://blog.seanssmith.com/posts/pywren-web-scraping.html)
  • 21.
  • 22.
    Takeaways ◉ Serverless isa fast & cost-effective way to deliver many use cases with Python ◉ New frontiers for Python (frameworks, tooling, etc.)
  • 23.
    Any questions? Thanks! Slides templateby SlidesCarnival Find me at @benikbauer This work is licensed under a CC Attribution 4.0 International License.