Two scoops of Django - Deployment
-
Upload
flywindy -
Category
Engineering
-
view
141 -
download
1
Transcript of Two scoops of Django - Deployment
Best Practices for Django 1.6
TWO SCOOPS OF DJANGO
Ch.27 Deployment: Platforms as a Service Ch.28 Deploying Django Project
Michelle Leu @flywindy 2015/07/14
ABOUT THIS BOOK
• Not really for new comer
• Author:
• Daniel Greenfeld & Audrey Roy
• Django Packages Website
• New version for Django 1.8
2
DEPLOYMENT
3
Platform as a Service (PaaS)
CLOUD SERVICE
4
Build Deploy Buy
EVALUATION
5
Compliance SSL/HTTPS, PCI Level 1 SSL/HTTPS
Pricing (Free Limit)
Sleeps after 30 mins of inactivity Must sleep 6 hours in a 24 hour period
one app, no custom domain, one app, MySQL.
Uptime 99.99x% ?
Staffing 24×7×365 (free in business hour) forums, stackoverflow
Scaling From command line / dashboard By switch diff pricing plan
Documentation Step by step tutorial (1.7) Wiki, Django 1.3
Performance 512 RAM, sleep 6hrs / day (free) low bandwidth, CPU allowance (free)
Geography United States or Europe Amazon's us-east-1c
Company stability Founded in 2007, acquired by Salesforce.com in 2010 PythonAnywhere LLP (2012)
LIVE DEMO ♥
6
7
• Project Layout
• Create Heroku app
• Setup environment variables
• Git push
• Django migrate
8
• Project Layout
• Open Bash console
• git clone, creating a virtualenv and pip install
• Setup environment variable
• Setup static files
• WSGI Settings
SUMMARY
9
Limit of app 5 1
Database PostgresSQL sqlite3, MySQL
Custom domain ✓ ✗ (only username)
Sleeping Sleeping at least 6hrs / day No sleeping
Scheduled tasks Heroku Scheduler (Unlimited) 1 daily task
Logging heroku logs Online log files (access, error, server)
Deployment Command line, more configs Online IDE / Console
DEPLOYMENT
10
Single-Server for Small Projects
SINGLE-SERVER FOR SMALL PROJECTS
11
HTTP + WSGI App
server
ProcessManager
DB Server
1. Nginx + uWSGI 2. Nginx + Gunicorn 3. Apache + mod_wsgi
1. Supervisord 2. init scripts
1. PostgresSQL 2. MySQL
DEPLOYMENT
12
Multi-Server for Medium to Large Projects
MULTI-SERVER FOR MEDIUM TO LARGE PROJECTS
13
HTTP + WSGI App
server
ProcessManager
DB Server
CDN for static
files
CachingServer
1. Redis for caching & async message queue 2. Memcached 3. Varnish
AUTOMATED, REPEATABLE DEPLOYMENTS
14
Remote execution
CURRENT INFRASTRUCTURE AUTOMATION TOOLS
• Installing packages
• Running commands on remote servers.
• Starting services, and restarting them under certain conditions.
• logging and returning the response from the server.
15
CURRENT INFRASTRUCTURE AUTOMATION TOOLS
16
Python
Ruby
SUMMARY
17
• Single-Server for Small Projects -> PaaS
• Multi-Server for Medium to Large Projects.
• Horizontal vs. Vertical Scaling
• Scaling Horizontally and Sessions
REFERENCE• http://twoscoopspress.org/products/two-scoops-of-django-1-6
• https://devcenter.heroku.com/
• https://www.pythonanywhere.com/wiki/
• http://djangogirlstaipei.gitbooks.io/django-girls-taipei-tutorial/content/django/deploy.html
• http://tutorial.djangogirls.org/en/deploy/index.html
18
THANKS FOR YOUR LISTENING