Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Two scoops of Django - Deployment

Two scoops of Django - Deployment

Two Scoops of Django Best Practices for Django 1.6
Ch.27 Deployment: Platforms as a Service
Ch.28 Deploying Django Project

flywindy

July 17, 2015
Tweet

More Decks by flywindy

Other Decks in Programming

Transcript

  1. 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
  2. ABOUT THIS BOOK • Not really for new comer •

    Author: • Daniel Greenfeld & Audrey Roy • Django Packages Website • New version for Django 1.8 2
  3. 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)
  4. 7 • Project Layout • Create Heroku app • Setup

    environment variables • Git push • Django migrate
  5. 8 • Project Layout • Open Bash console • git

    clone, creating a virtualenv and pip install • Setup environment variable • Setup static files • WSGI Settings
  6. 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
  7. SINGLE-SERVER FOR SMALL PROJECTS 11 HTTP + WSGI App server

    Process Manager DB Server 1. Nginx + uWSGI 2. Nginx + Gunicorn 3. Apache + mod_wsgi 1. Supervisord 2. init scripts 1. PostgresSQL 2. MySQL
  8. MULTI-SERVER FOR MEDIUM TO LARGE PROJECTS 13 HTTP + WSGI

    App server Process Manager DB Server CDN for static files Caching
 Server 1. Redis for caching & async message queue 2. Memcached 3. Varnish
  9. 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
  10. SUMMARY 17 • Single-Server for Small Projects -> PaaS •

    Multi-Server for Medium to Large Projects . • Horizontal vs. Vertical Scaling • Scaling Horizontally and Sessions