SlideShare a Scribd company logo
Building Serverless
applications with Python
Andrii Soldatenko
8 April 2017
Italy, Otto
@a_soldatenko
Andrii Soldatenko
• Senior Python Developer at
• CTO at
• Co-organizer PyCon Belarus 2017
• Speaker at many PyCons and open
source contributor
• blogger at https://asoldatenko.com
@a_soldatenko
…in the next few years we’re going to
see the first billion-dollar startup with a
single employee, the founder, and that
engineer will be using serverless
technology.
@a_soldatenko
James Governor
Analyst & Co-founder at RedMonk
Origins of “Serverless”
@a_soldatenko
Origins of
http://readwrite.com/2012/10/15/why-the-future-of-software-
and-apps-is-serverless/
Travis CI
Building serverless-applications
Later in 2014…
Amazon introduce
AWS Lambda
https://techcrunch.com/2015/11/24/aws-lamda-makes-
serverless-applications-a-reality/
What about conferences?
http://serverlessconf.io/
How Lambda works
@a_soldatenko
λ
@a_soldatenko
How Lambda works
@a_soldatenko
How Lambda works
- function name;
- memory size
- timeout;
- role;
@a_soldatenko
Your first λ function
def lambda_handler(event, context):
message = 'Hello {}!'.format(event['name'])
return {'message': message}
@a_soldatenko
Deploy λ function
#!/usr/bin/env bash
python -m zipfile -c hello_python.zip hello_python.py
aws lambda create-function 
--region us-west-2 
--function-name HelloPython 
--zip-file fileb://hello_python.zip 
--role arn:aws:iam::278117350010:role/lambda-s3-
execution-role 
--handler hello_python.my_handler 
--runtime python2.7 
--timeout 15 
--memory-size 512
@a_soldatenko
Invoke λ function
aws lambda invoke 
--function-name HelloPython 
--payload '{"name":"PyCon
Italy"}' output.txt
cat output.txt
{"message": "Hello PyCon Italy!"}%
@a_soldatenko
Amazon API Gateway
Resource HTTP verb
AWS
Lambda
/books GET get_books
/book POST create_book
/books/{ID} PUT chage_book
/books/{ID} DELETE delete_book
Chalice python
micro framework
https://github.com/awslabs/chalice
@a_soldatenko
Chalice python
micro framework
$ cat app.py

from chalice import Chalice
app = Chalice(app_name='hellopyconit')
@app.route('/books', methods=['GET'])
def get_books():
return {'hello': 'from python library'}

...

...
...
https://github.com/awslabs/chalice
...

...

...

@app.route('/books/{book_id}', methods=['POST', 'PUT', 'DELETE'])
def process_book(book_id):
request = app.current_request
if request.method == 'PUT':
return {'msg': 'Book {} changed'.format(book_id)}
elif request.method == 'DELETE':
return {'msg': 'Book {} deleted'.format(book_id)}
elif request.method == 'POST':
return {'msg': 'Book {} created'.format(book_id)}
Chalice python
micro framework
@a_soldatenko
Chalice deploy
chalice deploy
Updating IAM policy.
Updating lambda function...
Regen deployment package...
Sending changes to lambda.
API Gateway rest API already
found.
Deploying to: dev
https://8rxbsnge8d.execute-api.us-
west-2.amazonaws.com/dev/
@a_soldatenko
Try our books API
curl -XGET https://8rxbsnge8d.execute-
api.us-west-2.amazonaws.com/dev/books
{"hello": "from python library"}%
curl -XGET https://8rxbsnge8d.execute-
api.us-west-2.amazonaws.com/dev/books/15
{"message": "Book 15"}%
curl -XDELETE https://8rxbsnge8d.execute-
api.us-west-2.amazonaws.com/dev/books/15
{"message": "Book 15 has been deleted"}%
@a_soldatenko
Chalice under the hood
@a_soldatenko
- botocore;
- typing;
Chalice under the hood
@a_soldatenko
AWS Serverless
Application Model
@a_soldatenko
AWS SAM
@a_soldatenko
AWS lambda Limits
@a_soldatenko
AWS Lambda
without any costs
@a_soldatenko
- The first 400,000 seconds of
execution time with 1 GB of
memory
What if you want to run
your Django app?
@a_soldatenko
@a_soldatenko
@a_soldatenko
@a_soldatenko
And again what do you
mean “serveless”?
@a_soldatenko
➜ pip install zappa
➜ zappa init
███████╗ █████╗ ██████╗ ██████╗ █████╗
╚══███╔╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗
███╔╝ ███████║██████╔╝██████╔╝███████║
███╔╝ ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██║
███████╗██║ ██║██║ ██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝
Welcome to Zappa!
...
➜ zappa deploy
https://github.com/Miserlou/Zappa
@a_soldatenkohttps://github.com/Miserlou/Zappa
- deploy;
- tailing logs;
- run django manage.py

…
███████╗ █████╗ ██████╗ ██████╗ █████╗
╚══███╔╝██╔══██╗██╔══██╗██╔══██╗██╔══██╗
███╔╝ ███████║██████╔╝██████╔╝███████║
███╔╝ ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██║
███████╗██║ ██║██║ ██║ ██║ ██║
╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝
AWS lambda Limits
@a_soldatenko
Python 2.7
@a_soldatenko
Python 2.7 will retire
in...
@a_soldatenkohttps://pythonclock.org/
AWS lambda and
Python 3
@a_soldatenko
import os
def lambda_handler(event, context):
txt = open('/etc/issue')
print txt.read()
return {'message': txt.read()}
Amazon Linux AMI release 2016.03
Kernel r on an m
AWS lambda and
Python 3
@a_soldatenko
Linux ip-10-11-15-179 4.4.51-40.60.amzn1.x86_64 #1 SMP
Wed Mar 29 19:17:24 UTC 2017 x86_64 x86_64 x86_64 GNU/
Linux
import subprocess
def lambda_handler(event, context):
args = ('uname', '-a')
popen = subprocess.Popen(args,
stdout=subprocess.PIPE)
popen.wait()
output = popen.stdout.read()
print(output)
AWS lambda and
Python 3
@a_soldatenko
import subprocess
def lambda_handler(event, context):
args = ('which', 'python3')
popen = subprocess.Popen(args,
stdout=subprocess.PIPE)
popen.wait()
output = popen.stdout.read()
print(output)
python3: /usr/bin/python3 /usr/bin/python3.4m /usr/bin/
python3.4 /usr/lib/python3.4 /usr/lib64/python3.4 /usr/local/lib/
python3.4 /usr/include/python3.4m /usr/share/man/man1/
python3.1.gz
YAHOOO!!:
Run python 3 from
python 2
@a_soldatenko
Prepare Python 3 for
AWS Lambda
@a_soldatenko
virtualenv venv -p `which python3.4`
pip install requests
zip -r lambda_python3.zip venv
python3_program.py lambda.py
Run python 3 from
python 2
@a_soldatenko
cat lambda.py
import subprocess
def lambda_handler(event, context):
args = ('venv/bin/python3.4',
'python3_program.py')
popen = subprocess.Popen(args,
stdout=subprocess.PIPE)
popen.wait()
output = popen.stdout.read()
print(output)
Run python 3 from
python 2
@a_soldatenko
START RequestId: 44c89efb-1bd2-11e7-bf8c-83d444ed46f1
Version: $LATEST
Python 3.4.0
END RequestId: 44c89efb-1bd2-11e7-bf8c-83d444ed46f1
REPORT RequestId: 44c89efb-1bd2-11e7-bf8c-83d444ed46f1
Thanks Lyndon Swan
for ideas about hacking
python 3
@a_soldatenko
Future of serverless
@a_soldatenko
The biggest problem with Serverless FaaS right now is tooling.
Deployment / application bundling, configuration, monitoring /
logging, and debugging all need serious work.
https://github.com/awslabs/serverless-
application-model/blob/master/HOWTO.md
Thank You
andrii.soldatenko@toptal.com
https://asoldatenko.com
@a_soldatenko
Questions
? @a_soldatenko
We are hiring
https://www.toptal.com/#connect-
fantastic-computer-engineers

More Related Content

What's hot (20)

PPTX
Helpful Automation Techniques - Selenium Camp 2014
Justin Ison
 
PDF
Selenium conference, 2016
Pooja Shah
 
PDF
SeConf_Nov2016_London
Pooja Shah
 
PPTX
Cypress workshop for JSFoo 2019
Biswajit Pattanayak
 
PPTX
Engineering Tools at Netflix: Enabling Continuous Delivery
Mike McGarr
 
PDF
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Sauce Labs
 
PPTX
Introduction to cypress in Angular (Chinese)
Hong Tat Yew
 
PDF
Selenium Testing on Chrome - Google DevFest Armenia 2015
Sargis Sargsyan
 
PDF
Selenium Conference 2015 - Mobile Selenium Grid Setup
Justin Ison
 
PDF
Selenium Camp 2016 - Kiev, Ukraine
Justin Ison
 
PDF
Automation Best Practices
Sauce Labs
 
PPTX
Best Practices in Mobile CI (webinar)
Sauce Labs
 
PPTX
Build Automation in Android
Angelo Rüggeberg
 
PDF
Midwest PHP 2017 DevOps For Small team
Joe Ferguson
 
PPTX
Moving From a Selenium Grid to the Cloud - A Real Life Story
Sauce Labs
 
PPTX
Continuous Testing in the Cloud
Sauce Labs
 
PDF
Testing desktop apps with selenium
Filip Braun
 
PDF
An Introduction to Appium Desktop
Sauce Labs
 
PDF
Belfast Selenium Meetup
Justin Ison
 
PDF
Selenium and Sauce Labs
hugs
 
Helpful Automation Techniques - Selenium Camp 2014
Justin Ison
 
Selenium conference, 2016
Pooja Shah
 
SeConf_Nov2016_London
Pooja Shah
 
Cypress workshop for JSFoo 2019
Biswajit Pattanayak
 
Engineering Tools at Netflix: Enabling Continuous Delivery
Mike McGarr
 
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Sauce Labs
 
Introduction to cypress in Angular (Chinese)
Hong Tat Yew
 
Selenium Testing on Chrome - Google DevFest Armenia 2015
Sargis Sargsyan
 
Selenium Conference 2015 - Mobile Selenium Grid Setup
Justin Ison
 
Selenium Camp 2016 - Kiev, Ukraine
Justin Ison
 
Automation Best Practices
Sauce Labs
 
Best Practices in Mobile CI (webinar)
Sauce Labs
 
Build Automation in Android
Angelo Rüggeberg
 
Midwest PHP 2017 DevOps For Small team
Joe Ferguson
 
Moving From a Selenium Grid to the Cloud - A Real Life Story
Sauce Labs
 
Continuous Testing in the Cloud
Sauce Labs
 
Testing desktop apps with selenium
Filip Braun
 
An Introduction to Appium Desktop
Sauce Labs
 
Belfast Selenium Meetup
Justin Ison
 
Selenium and Sauce Labs
hugs
 

Similar to Building serverless-applications (20)

PDF
Origins of Serverless
Andrii Soldatenko
 
PDF
Building Serverless applications with Python
Andrii Soldatenko
 
PDF
Try! Swift Tokyo2017
Amy Cheong
 
PDF
Serverless in production, an experience report
Yan Cui
 
PDF
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
PDF
DevOps + MongoDB Realm Serverless Functions = 🤩
Lauren Hayward Schaefer
 
PDF
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
PDF
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
PPTX
DevOps + MongoDB Serverless = 
Lauren Hayward Schaefer
 
ODP
Introduce Django
Chui-Wen Chiu
 
PDF
Migrating Web SDK from JS to TS
Grigory Petrov
 
PDF
SoundCloud API Do:s and Don't:s
Eric Wahlforss
 
PDF
API-First Design and Django
Klaus Peter Laube
 
PDF
Overboard.js - where are we going with with jsconfasia / devfestasia
Christian Heilmann
 
PPTX
Kiwipycon command line
Michael Hudson-Doyle
 
PDF
Building an Open Source iOS app: lessons learned
Wojciech Koszek
 
PPTX
SaaS Boilerplate.pptx
DuyKhi8
 
PDF
Jets: The Ruby Serverless Framework Ruby Kaigi Japan 2019 April
Tung Nguyen
 
PDF
Understanding and building Your Own Docker
Motiejus Jakštys
 
PDF
Metasepi team meeting #16: Safety on ATS language + MCU
Kiwamu Okabe
 
Origins of Serverless
Andrii Soldatenko
 
Building Serverless applications with Python
Andrii Soldatenko
 
Try! Swift Tokyo2017
Amy Cheong
 
Serverless in production, an experience report
Yan Cui
 
Serverless in Production, an experience report (AWS UG South Wales)
Yan Cui
 
DevOps + MongoDB Realm Serverless Functions = 🤩
Lauren Hayward Schaefer
 
Serverless in production, an experience report (CoDe-Conf)
Yan Cui
 
Serverless in production, an experience report (FullStack 2018)
Yan Cui
 
DevOps + MongoDB Serverless = 
Lauren Hayward Schaefer
 
Introduce Django
Chui-Wen Chiu
 
Migrating Web SDK from JS to TS
Grigory Petrov
 
SoundCloud API Do:s and Don't:s
Eric Wahlforss
 
API-First Design and Django
Klaus Peter Laube
 
Overboard.js - where are we going with with jsconfasia / devfestasia
Christian Heilmann
 
Kiwipycon command line
Michael Hudson-Doyle
 
Building an Open Source iOS app: lessons learned
Wojciech Koszek
 
SaaS Boilerplate.pptx
DuyKhi8
 
Jets: The Ruby Serverless Framework Ruby Kaigi Japan 2019 April
Tung Nguyen
 
Understanding and building Your Own Docker
Motiejus Jakštys
 
Metasepi team meeting #16: Safety on ATS language + MCU
Kiwamu Okabe
 
Ad

More from Andrii Soldatenko (8)

PDF
Debugging concurrency programs in go
Andrii Soldatenko
 
PDF
Building robust and friendly command line applications in go
Andrii Soldatenko
 
PDF
Advanced debugging  techniques in different environments
Andrii Soldatenko
 
PDF
Building social network with Neo4j and Python
Andrii Soldatenko
 
PDF
What is the best full text search engine for Python?
Andrii Soldatenko
 
PDF
Kyiv.py #16 october 2015
Andrii Soldatenko
 
PDF
PyCon Russian 2015 - Dive into full text search with python.
Andrii Soldatenko
 
PDF
PyCon 2015 Belarus Andrii Soldatenko
Andrii Soldatenko
 
Debugging concurrency programs in go
Andrii Soldatenko
 
Building robust and friendly command line applications in go
Andrii Soldatenko
 
Advanced debugging  techniques in different environments
Andrii Soldatenko
 
Building social network with Neo4j and Python
Andrii Soldatenko
 
What is the best full text search engine for Python?
Andrii Soldatenko
 
Kyiv.py #16 october 2015
Andrii Soldatenko
 
PyCon Russian 2015 - Dive into full text search with python.
Andrii Soldatenko
 
PyCon 2015 Belarus Andrii Soldatenko
Andrii Soldatenko
 
Ad

Recently uploaded (20)

PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PDF
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PDF
What companies do with Pharo (ESUG 2025)
ESUG
 
PDF
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
PDF
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
PDF
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
PPTX
Presentation about Database and Database Administrator
abhishekchauhan86963
 
PPTX
Explanation about Structures in C language.pptx
Veeral Rathod
 
PPTX
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
advancepresentationskillshdhdhhdhdhdhhfhf
jasmenrojas249
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
What companies do with Pharo (ESUG 2025)
ESUG
 
AWS_Agentic_AI_in_Indian_BFSI_A_Strategic_Blueprint_for_Customer.pdf
siddharthnetsavvies
 
Virtual Threads in Java: A New Dimension of Scalability and Performance
Tier1 app
 
Presentation about variables and constant.pptx
kr2589474
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
System Center 2025 vs. 2022; What’s new, what’s next_PDF.pdf
Q-Advise
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
slidesgo-unlocking-the-code-the-dynamic-dance-of-variables-and-constants-2024...
kr2589474
 
Presentation about Database and Database Administrator
abhishekchauhan86963
 
Explanation about Structures in C language.pptx
Veeral Rathod
 
Employee salary prediction using Machine learning Project template.ppt
bhanuk27082004
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 

Building serverless-applications