Presentation from Django User Group London, June 2017
How to run Django on AWS Lambda - with demo of getting a hello world deployed in less than 10 minutes
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
DJUGL - Django and AWS Lambda
1. Django and AWS
Lambda
Malcolm Box
malcolm.box@gmail.com
Sometimes: @malcolmbox
Very occasionally: https://attentionshard.wordpress.com
2. About me
• Working with Django since 2009 (Django 1.1)
• CTO of Tellybug where we made apps for TV
shows and a very scalable platform using Django
& AWS
• Recently started building a new project using
serverless
• Consulting CTO working with startups
3. “AWS Lambda is a compute service that
lets you run code without provisioning or
managing servers”
11. Asynchronous Task
Execution
from flask import Flask
from zappa.async import task
app = Flask(__name__)
@task
def make_pie():
""" This takes a long time! """
ingredients = get_ingredients()
pie = bake(ingredients)
deliver(pie)
@app.route('/api/order/pie')
def order_pie():
""" This returns immediately! """
make_pie()
return "Your pie is being made!"
12. Going further
• Database - can use RDS, Dynamo, Redshift etc
• GeoDjango & binary libraries - issues if they get
too big
• Python 3 - now supported
• Static files - use Whitenoise
http://whitenoise.evans.io
Serverless is the architectural pattern
Google Cloud Functions and AWS Lambda are (two) examples
Runs Python, Java or Javascript code in response to events
No servers...
Not permanent
Not managed by you
Not paid for unless *doing* something for you
“Hey, I wanna serve a web page”
1990s - build a data centre
2000s - Hosting
2006 - AWS
2013 - Docker
2014 - AWS Lambda
Serverless Python Web Services
Django or Flask on Lambda
Scheduled tasks running as AWS lambda functions
VPC wrangling for RDS + API Gateway - you need two VPCs with Internet gateways. This is not well documented!