This is a demo implementation of an Application-based Blue/Green Deployment in Django. If you don't know what Blue/Green Deployment is, Martin Fowler is always a great starting point.
App-based Blue/Green Deployment is similar to a regular Blue/Green, but all the blue/green mechanisms are implemented inside a single app, talking with one database that supports only one schema structure at a given moment. This greatly simplifies the complexity of maintaining data consistency, without any degragation in the user experience (no need for read-only mode).
This is an experimental approach, and this project shows a complete working walkthrough of a naively simple case. I'd love to hear if you tried it in a more complex setting, and whether you succeeded or faced problems that failed the approach.
This project is the companion of this talk, originally given at PyWeb-IL. Both the talk and the repo are standalones, and each can (hopefully) be understood without the other.
Credits: This implementation heavily draws on https://github.com/jazzband/django-hosts, and on work done by my team and I at MassChallenge Inc..
Comments, suggestions and spin-offs are more than welcome.
- Python 3.6
- Django 2.0
- Git installed locally.
- Project is cloned locally.
git checkout step-1
./manage.py migrate
./manage.py runserver <port>
- go to: http://localhost:port/books/ - see green app serving initial data.
git checkout step-2
- Server restarts (Automatically). see green app still serving, through router app.
git checkout step-3
./manage.py migrate blue --fake
- Server restarts. See green app still serving, through router app. Blue app is exact copy of green, waiting to be changed
git checkout step-4
(server restarts)./manage.py migrate
- See project switches to Blue app immediately, by appliying the migration.
./manage.py migrate green zero --fake
git checkout step-5
- See blue app serving, now project has one app, migration is complete.