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

Django 1.7 on App Engine

Django 1.7 on App Engine

Django was actively supported at an early stage of the Python runtime in App Engine SDK through the notable django-nonrel framework, a fork of the original project that adds support for NoSql databases. But starting from the App Engine SDK 1.6.2, released more than two years ago, you can instead deploy Django’s official releases and take advantages from the whole stack of the framework.

In less than half an hour we’ll see how we can easily deploy the latest version of Django on the Google Cloud Platform, taking advantage of the tools and services provided by App Engine, Cloud SQL and Cloud Storage.

Massimiliano Pippi

April 18, 2015
Tweet

More Decks by Massimiliano Pippi

Other Decks in Programming

Transcript

  1. Django 1.7 on App Engine
    It could work!

    View Slide

  2. Massimiliano Pippi
    dev.pippi.im
    @maxpippi

    View Slide

  3. View Slide

  4. View Slide

  5. ● 2008: App Engine dev preview release
    ● 2009: Django 1.0 added to the Python runtime
    ● 2011: django-nonrel
    ● [ … ]
    ● 2014: Cloud Sql GA release

    View Slide

  6. View Slide

  7. pip install django -t /path/to/application/root
    # gae.pth
    /usr/local/google_appengine
    import dev_appserver; dev_appserver.fix_sys_path()
    import sys; sys.path.insert(1, ‘/path/to/application/root’)
    How?

    View Slide

  8. Why?

    View Slide

  9. Managed DB instances
    Cloud SQL
    ● fully managed: up and down scaling
    ● replication, patch management, backups
    ● no data lock-in
    ● MySql 5.5 and 5.6 available
    don’t be a jerk on MySql!

    View Slide

  10. Media storage
    Google Cloud Storage
    ● S3 fashioned file storage (versioning, CDN,
    ACLs, …)
    ● django media files (static files are smoothly
    handled by app engine by itself)
    ● no lock-in: implemented as a django custom
    file storage

    View Slide

  11. In-memory caching
    Memcache
    ● shared or dedicated instances
    ● monitoring tools come for free
    ● no lock-in: implemented as a django cache
    backend

    View Slide

  12. Asynchronous tasks
    Task Queue
    ● automatic scaling
    ● no more celery / python-rq
    ● workers hit http endpoints

    View Slide

  13. Push notifications
    Google Channel API
    ● provides js client via CDN
    ● easy to use
    ● not well suited if latency is key

    View Slide

  14. Authentication
    A non-feature of the Google Cloud Platform
    Getting rid of the Google Authentication
    system
    Use the more flexible Django contrib.auth
    framework instead

    View Slide

  15. External resources
    github.com/masci/django-appengine-toolkit
    ● no need to pip install -t
    ● memcache as cache backend ootb
    ● cloud storage as storage backend ootb
    ● database config from env vars

    View Slide

  16. Why not?
    Technology lock-in depending on the Google
    Cloud components in use
    Cloud SQL has no free tiers
    Python 2 only :(

    View Slide

  17. Thank you!
    dev.pippi.im
    @maxpippi

    View Slide