Slide 1

Slide 1 text

Python in The Serverless Era Photo by Zack Spear Icon by Serverless

Slide 2

Slide 2 text

◉ Chief Architect @ ◉ Ex- : Cloud Architect @ AutoCAD ◉ Find me at @benikbauer I am Benny Bauer Hello!

Slide 3

Slide 3 text

What is Serverless Dev SaaS BaaS FaaS

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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...

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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.

Slide 9

Slide 9 text

Let’s get to business! Python & FaaS

Slide 10

Slide 10 text

Cloud providers Python 2.7 & 3.6 are supported by: ● AWS ● OpenWhisk ● Microsoft Azure - experimental, still not GA

Slide 11

Slide 11 text

Configuration - Event binding - Resources definition - Security roles definition The need for frameworks Deployment - Package - Upload - Rollback

Slide 12

Slide 12 text

Frameworks Chalice

Slide 13

Slide 13 text

Serverless Framework

Slide 14

Slide 14 text

Zappa One function only. Serves as a WSGI server WSGI

Slide 15

Slide 15 text

Unique features: ● Global deployment ● “Keep warm” functionality ● SSL certification ● Support for AWS Lambda compatible python libraries (lambda-packages & Manylinux wheels) Zappa

Slide 16

Slide 16 text

● Python Serverless Microframework for AWS ● Each endpoint is a separate function Chalice

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Unique features: ● Automatic IAM policy generation Chalice

Slide 19

Slide 19 text

Pywren

Slide 20

Slide 20 text

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)

Slide 21

Slide 21 text

Summary What was it all about?

Slide 22

Slide 22 text

Takeaways ◉ Serverless is a fast & cost-effective way to deliver many use cases with Python ◉ New frontiers for Python (frameworks, tooling, etc.)

Slide 23

Slide 23 text

Any questions? Thanks! Slides template by SlidesCarnival Find me at @benikbauer This work is licensed under a CC Attribution 4.0 International License.