SlideShare une entreprise Scribd logo
1  sur  13
Django and AWS
Lambda
Malcolm Box
malcolm.box@gmail.com
Sometimes: @malcolmbox
Very occasionally: https://attentionshard.wordpress.com
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
“AWS Lambda is a compute service that
lets you run code without provisioning or
managing servers”
Data Centre
Server
Linux
nginx
gunicorn
Django
def view(request):
return
render(request,
"demo.html")
*Not to scale
https://github.com/Miserlou/Zappa
Demo!
• You will need:
• AWS Credentials
• A python virtualenv
• Instructions and example code:
https://github.com/mbox/djugl-demo
Other Zappa goodness
$ zappa tail
Calling tail for stage demo..
[1497350426182] [DEBUG] 2017-06-13T10:40:26.182Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce Zappa Event: {u'body': None, u'resource':
u'/', u'requestContext': {u'resourceId': u'gm6q48zq93', u'apiId': u'lkvzkzlzd6', u'resourcePath': u'/', u'httpMethod': u'GET', u'requestId':
u'b54d0e51-5024-11e7-b059-6324c1a6f402', u'path': u'/demo', u'accountId': u'956653133436', u'identity': {u'apiKey': u'', u'userArn': None,
u'cognitoAuthenticationType': None, u'accessKey': None, u'caller': None, u'userAgent': u'python-requests/2.17.3', u'user': None,
u'cognitoIdentityPoolId': None, u'cognitoIdentityId': None, u'cognitoAuthenticationProvider': None, u'sourceIp': u'82.3.163.138', u'accountId':
None}, u'stage': u'demo'}, u'queryStringParameters': None, u'httpMethod': u'GET', u'pathParameters': None, u'headers': {u'Via': u'1.1
2e578cf3c3154a7d5d4f253d74c2b940.cloudfront.net (CloudFront)', u'Accept-Encoding': u'gzip, deflate', u'CloudFront-Is-SmartTV-Viewer':
u'false', u'CloudFront-Forwarded-Proto': u'https', u'X-Forwarded-For': u'82.3.163.138, 54.182.244.97', u'CloudFront-Viewer-Country': u'GB',
u'Accept': u'*/*', u'User-Agent': u'python-requests/2.17.3', u'X-Amzn-Trace-Id': u'Root=1-593fc118-7e2199041b9cd95f3abfe753', u'Host':
u'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com', u'X-Forwarded-Proto': u'https', u'X-Amz-Cf-Id': u'1Cn8Ygt_ftJmfKnGiNqCTOO2SNT-
gcNigAY0DXARyP2O500N8oEZGQ==', u'CloudFront-Is-Tablet-Viewer': u'false', u'X-Forwarded-Port': u'443', u'CloudFront-Is-Mobile-Viewer':
u'false', u'CloudFront-Is-Desktop-Viewer': u'true'}, u'stageVariables': None, u'path': u'/', u'isBase64Encoded': False}
[1497350426184] Invalid HTTP_HOST header: 'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com'. You may need to add u'lkvzkzlzd6.execute-
api.eu-west-1.amazonaws.com' to ALLOWED_HOSTS.
[1497350426184] [ERROR] 2017-06-13T10:40:26.183Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce Invalid HTTP_HOST header:
'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com'. You may need to add u'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com' to
ALLOWED_HOSTS.
[1497350426341] [INFO] 2017-06-13T10:40:26.341Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce 82.3.163.138 - - [13/Jun/2017:10:40:26 +0000]
"GET / HTTP/1.1" 400 37968 "" "python-requests/2.17.3" 0/158.477
zappa manage
$ zappa manage demo migrate
START RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0 Version: $LATEST
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
No migrations to apply.
END RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0
REPORT RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0Duration: 386.42 msBilled Duration: 400 ms
Memory Size: 512 MB Max Memory Used: 52 MB
zappa schedule
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!"
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
Thank you!

Contenu connexe

Tendances

DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webminpostrational
 
Coolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & DeploymentCoolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & DeploymentMatthew Hodgkins
 
Put kajakken på hylden - og få sexede windows services
Put kajakken på hylden - og få sexede windows servicesPut kajakken på hylden - og få sexede windows services
Put kajakken på hylden - og få sexede windows servicesChristian Dalager
 
Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerErik Osterman
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioRick Copeland
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglKilian Valkhof
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the thingsJohn Cleary
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Running azure function locally
Running azure function locallyRunning azure function locally
Running azure function locallyCelso Junior
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual InfrastructureBryan McLellan
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudSimone Soldateschi
 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resquehomanj
 
asyncio community, one year later
asyncio community, one year laterasyncio community, one year later
asyncio community, one year laterVictor Stinner
 

Tendances (19)

DevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and WebminDevOps tools for everyone - Vagrant, Puppet and Webmin
DevOps tools for everyone - Vagrant, Puppet and Webmin
 
Coolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & DeploymentCoolblue - Behind the Scenes Continuous Integration & Deployment
Coolblue - Behind the Scenes Continuous Integration & Deployment
 
Put kajakken på hylden - og få sexede windows services
Put kajakken på hylden - og få sexede windows servicesPut kajakken på hylden - og få sexede windows services
Put kajakken på hylden - og få sexede windows services
 
Getting started with node.js
Getting started with node.jsGetting started with node.js
Getting started with node.js
 
Bundler
BundlerBundler
Bundler
 
Write php deploy everywhere
Write php deploy everywhereWrite php deploy everywhere
Write php deploy everywhere
 
Speeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue ServerSpeeding up Page Load Times by Using the Starling Queue Server
Speeding up Page Load Times by Using the Starling Queue Server
 
Real-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.ioReal-Time Python Web: Gevent and Socket.io
Real-Time Python Web: Gevent and Socket.io
 
Html5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webglHtml5, css3, canvas, svg and webgl
Html5, css3, canvas, svg and webgl
 
Designing net-aws-glacier
Designing net-aws-glacierDesigning net-aws-glacier
Designing net-aws-glacier
 
Start using vagrant now!
Start using vagrant now!Start using vagrant now!
Start using vagrant now!
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Running azure function locally
Running azure function locallyRunning azure function locally
Running azure function locally
 
Capistrano
CapistranoCapistrano
Capistrano
 
Virtual Infrastructure
Virtual InfrastructureVirtual Infrastructure
Virtual Infrastructure
 
PyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the CloudPyCon Russia 2014 - Auto Scale in the Cloud
PyCon Russia 2014 - Auto Scale in the Cloud
 
Background Jobs with Resque
Background Jobs with ResqueBackground Jobs with Resque
Background Jobs with Resque
 
asyncio community, one year later
asyncio community, one year laterasyncio community, one year later
asyncio community, one year later
 

Similaire à DJUGL - Django and AWS Lambda

Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Chef
 
Easy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadBram Vogelaar
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale Subbu Allamaraju
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!Jeff Anderson
 
Advanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesHiroshi SHIBATA
 
how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack apiLiang Bo
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...NGINX, Inc.
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Develcz
 
Future of Serverless
Future of ServerlessFuture of Serverless
Future of ServerlessYoav Avrahami
 
Try to use chromeless on AWS Lambda
Try to use chromeless on AWS LambdaTry to use chromeless on AWS Lambda
Try to use chromeless on AWS LambdaRyo Shibayama
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultGrzegorz Adamowicz
 
Lights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverLights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverbridgetkromhout
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversTatsuhiko Miyagawa
 

Similaire à DJUGL - Django and AWS Lambda (20)

Pyrax talk
Pyrax talkPyrax talk
Pyrax talk
 
Cooking Up Drama
Cooking Up DramaCooking Up Drama
Cooking Up Drama
 
Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015 Cooking Up Drama - ChefConf 2015
Cooking Up Drama - ChefConf 2015
 
PSGI/Plack OSDC.TW
PSGI/Plack OSDC.TWPSGI/Plack OSDC.TW
PSGI/Plack OSDC.TW
 
Easy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp Nomad
 
ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale ql.io: Consuming HTTP at Scale
ql.io: Consuming HTTP at Scale
 
NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!NGINX Can Do That? Test Drive Your Config File!
NGINX Can Do That? Test Drive Your Config File!
 
Advanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutesAdvanced technic for OS upgrading in 3 minutes
Advanced technic for OS upgrading in 3 minutes
 
how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack api
 
About Clack
About ClackAbout Clack
About Clack
 
MesosCon - Be a microservices hero
MesosCon - Be a microservices heroMesosCon - Be a microservices hero
MesosCon - Be a microservices hero
 
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
Session: A Reference Architecture for Running Modern APIs with NGINX Unit and...
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Mangling
Mangling Mangling
Mangling
 
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
Ondřej Šika: Docker, Traefik a CI - Mějte nasazené všeny větve na kterých pra...
 
Future of Serverless
Future of ServerlessFuture of Serverless
Future of Serverless
 
Try to use chromeless on AWS Lambda
Try to use chromeless on AWS LambdaTry to use chromeless on AWS Lambda
Try to use chromeless on AWS Lambda
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp Vault
 
Lights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFeverLights, Camera, Docker: Streaming Video at DramaFever
Lights, Camera, Docker: Streaming Video at DramaFever
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
 

Dernier

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+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”
  • 4.
  • 7. Demo! • You will need: • AWS Credentials • A python virtualenv • Instructions and example code: https://github.com/mbox/djugl-demo
  • 8. Other Zappa goodness $ zappa tail Calling tail for stage demo.. [1497350426182] [DEBUG] 2017-06-13T10:40:26.182Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce Zappa Event: {u'body': None, u'resource': u'/', u'requestContext': {u'resourceId': u'gm6q48zq93', u'apiId': u'lkvzkzlzd6', u'resourcePath': u'/', u'httpMethod': u'GET', u'requestId': u'b54d0e51-5024-11e7-b059-6324c1a6f402', u'path': u'/demo', u'accountId': u'956653133436', u'identity': {u'apiKey': u'', u'userArn': None, u'cognitoAuthenticationType': None, u'accessKey': None, u'caller': None, u'userAgent': u'python-requests/2.17.3', u'user': None, u'cognitoIdentityPoolId': None, u'cognitoIdentityId': None, u'cognitoAuthenticationProvider': None, u'sourceIp': u'82.3.163.138', u'accountId': None}, u'stage': u'demo'}, u'queryStringParameters': None, u'httpMethod': u'GET', u'pathParameters': None, u'headers': {u'Via': u'1.1 2e578cf3c3154a7d5d4f253d74c2b940.cloudfront.net (CloudFront)', u'Accept-Encoding': u'gzip, deflate', u'CloudFront-Is-SmartTV-Viewer': u'false', u'CloudFront-Forwarded-Proto': u'https', u'X-Forwarded-For': u'82.3.163.138, 54.182.244.97', u'CloudFront-Viewer-Country': u'GB', u'Accept': u'*/*', u'User-Agent': u'python-requests/2.17.3', u'X-Amzn-Trace-Id': u'Root=1-593fc118-7e2199041b9cd95f3abfe753', u'Host': u'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com', u'X-Forwarded-Proto': u'https', u'X-Amz-Cf-Id': u'1Cn8Ygt_ftJmfKnGiNqCTOO2SNT- gcNigAY0DXARyP2O500N8oEZGQ==', u'CloudFront-Is-Tablet-Viewer': u'false', u'X-Forwarded-Port': u'443', u'CloudFront-Is-Mobile-Viewer': u'false', u'CloudFront-Is-Desktop-Viewer': u'true'}, u'stageVariables': None, u'path': u'/', u'isBase64Encoded': False} [1497350426184] Invalid HTTP_HOST header: 'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com'. You may need to add u'lkvzkzlzd6.execute- api.eu-west-1.amazonaws.com' to ALLOWED_HOSTS. [1497350426184] [ERROR] 2017-06-13T10:40:26.183Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce Invalid HTTP_HOST header: 'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com'. You may need to add u'lkvzkzlzd6.execute-api.eu-west-1.amazonaws.com' to ALLOWED_HOSTS. [1497350426341] [INFO] 2017-06-13T10:40:26.341Z b55a7b0b-5024-11e7-8e46-47e2239fb3ce 82.3.163.138 - - [13/Jun/2017:10:40:26 +0000] "GET / HTTP/1.1" 400 37968 "" "python-requests/2.17.3" 0/158.477
  • 9. zappa manage $ zappa manage demo migrate START RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0 Version: $LATEST Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions Running migrations: No migrations to apply. END RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0 REPORT RequestId: da3e8e84-5039-11e7-9c38-2913a464f8e0Duration: 386.42 msBilled Duration: 400 ms Memory Size: 512 MB Max Memory Used: 52 MB
  • 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

Notes de l'éditeur

  1. 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...
  2. Not permanent Not managed by you Not paid for unless *doing* something for you
  3. “Hey, I wanna serve a web page” 1990s - build a data centre 2000s - Hosting 2006 - AWS 2013 - Docker 2014 - AWS Lambda
  4. Serverless Python Web Services Django or Flask on Lambda
  5. Scheduled tasks running as AWS lambda functions
  6. VPC wrangling for RDS + API Gateway - you need two VPCs with Internet gateways. This is not well documented!