Deployment

Deployment involves packaging up your web application and putting it in a production environment that can run the app.

Why is deployment necessary?

Your web application must live somewhere other than your own desktop or laptop. A production environment is the canonical version of your current application and its associated data.

Deployment topics map

Python web application deployments are comprised of many pieces that need to be individually configured. Here is a map that visually depicts how each deployment topic relates to each other. Click the image to pull up a PDF version.

Full Stack Python deployments map.

Deployment hosting options

There are four options for deploying and hosting a web application:

  1. "Bare metal" servers

  2. Virtualized servers

  3. Infrastructure-as-a-service

  4. Platform-as-a-service

The first three options are similar. The deployer needs to provision one or more servers with a Linux distribution. System packages, a web server, WSGI server, database and the Python environment are then installed. Finally the application can be pulled from source and installed in the environment.

Note that there are other ways of installing a Python web application through system-specific package management systems. We won't cover those in this guide as they are considered advanced deployment techniques.

Deployment resources

  • If you need a step-by-step guide to deploying a Python web application, I wrote a whole book on exactly this topic called The Full Stack Python Guide to Deployments that you'll find super helpful.

  • Deploying Python web applications is an episode of the great Talk Python to Me podcast series where I discuss deploying web applications based on a fairly traditional virtual private server, Nginx and Green Unicorn stack.

  • Thoughts on web application deployment walks through stages of deployment with source control, planning, continuous deployment and monitoring the results.

  • Deploying Software is a long must-read for understanding how to deploy software properly.

  • Hands-off deployment with Canary explains how SoundCloud automates their deployment process and uses canary builds to identify and roll back issues to mitigate reliability issues that can occur with shipping software at scale.

  • Practical continuous deployment defines delivery versus deployment and walks through a continuous deployment workflow.

  • Automation for the People provides an awesome overview of one developer's story for how he gradually learned about deployment automation. The story follows my own journey in many ways, from starting with brittle Bash scripts, moving to Fabric and then on to Ansible for higher-level configuration management and continuous deployment pipelines.

  • 5 ways to deploy your Python application in 2017 is a talk from PyCon US 2017 where Andrew Baker deploys the getting started Flask app using Ngrok, Heroku, Zappa on the serverless AWS Lambda platform, a virtual machine on Google Cloud and Docker.

  • Continuous deployment at Instagram is the story of how their deployment process evolved over time from a large Fabric script to continuous deployments. Along the way they encountered issues with code reviews, test failures, canary builds and rollbacks. It's a great read that sheds some light on how Python deployments can be done well at large scale.

  • Stack Overflow's guide on how they do deployment is an awesome in-depth read covering topics ranging from git branching to database migrations.

  • In this free video by Neal Ford, he talks about engineering practices for continuous delivery. He explains the difference between continuous integration, continuous deployment and continuous delivery. Highly recommended for an overview of deployment concepts and as an introduction to the other videos on those subjects in that series.

  • If you're using Flask this detailed post on deploying it to Ubuntu is a great way to familiarize yourself with the deployment process.

  • TestDriven.io shows how to deploy a microservices architecture that uses Docker, Flask, and React with container orchestration on Amazon ECS.

Deployment learning checklist

  1. If you're tight on time look at the platform-as-a-service (PaaS) options. You can deploy a low traffic project web app for free or low cost. You won't have to worry about setting up the operating system and web server compared to going the traditional server route. In theory you should be able to get your application live on the web sooner with PaaS hosting.

  2. Traditional server options are your best bet for learning how the entire Python web stack works. You'll often save money with a virtual private server instead of a platform-as-a-service as you scale up.

  3. Read about servers, operating systems, web servers and WSGI servers to get a broad picture of what components need to be set up to run a Python web application.

您想如何部署您的网络应用程序?

向我展示裸机和虚拟化服务器的选项。

如何使用平台即服务(PaaS)来部署我的 Python 应用程序?

我有一台服务器,如何设置操作系统?

Sign up for a monthly email with Full Stack Python tutorials. No spam ever.