like the polls tutorial • Created your own web app • e.g. for keeping track of your family culinary recipes • everything is running nicely on http://localhost:8000 • now how do you let your users access the app?
We’d go for nginx • Now a problem is nginx (or Apache) doesn’t support Django directly • python manage.py runserver ? • We need to set up a production-ready application server like uWSGI (or gunicorn) that knows how to run our Django app • Then we need to conﬁgure nginx as a passthrough for this server… except for static / media ﬁles… those need to be served by nginx
A record if you have a ﬁxed IP • CNAME if you’re forwarding to another domain • just note that CNAME on the root domain doesn’t always play nicely with MX rules • check if there is ANAME / ALIAS support • or connect your app via a subdomain like app.mydomain.com
responsible for maintaining them • They will break and change over time • We need to keep our Django app conﬁgured to know where everything is • Can this be automated? • To an extent, yes – there are conﬁg management tools like Ansible (of Salt, Chef, Puppet) • But there are better ways…
in revision control, many deploys • II. Dependencies – Explicitly declare and isolate dependencies • III. Conﬁg – Store conﬁg in the environment • IV. Backing services – Treat backing services as attached resources • V. Build, release, run – Strictly separate build and run stages • VI. Processes – Execute the app as one or more stateless processes • VII. Port binding – Export services via port binding • VIII. Concurrency – Scale out via the process model • IX. Disposability – Maximize robustness with fast startup and graceful shutdown • X. Dev/prod parity – Keep development, staging, and production as similar as possible • XI. Logs – Treat logs as event streams • XII. Admin processes – Run admin/management tasks as one-oﬀ processes
can easily become $14 / month if you need periodic tasks – where you need a scheduler • If you have more than one project running these things add up • If you’re not making money from those apps, that cost could be diﬃcult to justify • Luckily the open source world has our back!
Can be self-hosted on a $5 / month Digital Ocean droplet • Or a €3 / month Scaleway VM if you prefer something inside the EU • Dokku has some of the drawbacks of self-hosting, but it respects the 12-factor methodology so it’s much easier to maintain • Treat your servers as cattle, not as pets!
you only have a small number of users (if any) • Eventually, your app might start getting serious traﬃc • Scaling of Django apps • a separate topic • lots of good talks on https://pyvideo.org/ (old PyCons)
Other AWS services – RDS etc. • Hosted Kubernetes solutions • Serverless • Serve a Django App from AWS Lambda • Diﬀerent architecture • Are these the best approaches when you’re getting started • Probably not – you’re exploring what app your users might like • Only when you’ve found something worthwhile does it make sense to put more energy into scalability • When you do, however, ﬁnd the right help – good DevOps engineers