When you finish your django project the very next step is to deploy it to the production server. You might have already setup a development server to show you project to others(may be your customers). 
Here I am not discussing about development but about deployment in production server - the final step to take your project live.

The Django supports many ways to deploy the project to production- you can use your favourite web server, database, proxy, and so on.

 

Example architecture of django production server 

Django-host

Core stack

  1. Apache, nginx, lighttpd, cherokee
  2. mod_python, mode_wsgi, Gunicorn, uwsgi, FastCGI
  3. Supervisor 
  4. MySQL/ Postgres/ Other databases 
  5. Celery, cron
  6. RabbitMQ, Redis
  7. Memcached

Webserver

A Web server is a program that uses the client/server model and the World Wide Web's Hypertext Transfer Protocol ( HTTP ) to  serve the files from Web pages to Web users (whose computers contain HTTP clients that forward their requests). There are many web servers available for us to choose from. We can use any of  Apache, nginx or lighttpd. But when we choose a web server we need to select an appropriate submodule compatible to it from mod_python, mode_wsgi, Gunicorn, uwsgi, FastCGI. For example we can use apache with mod_python or mode_wsgi, nginx with uwsgi or gunicorn.

Background Tasks

There are some tasks which will take a very long time finish and a user need not to wait for its result. In such cases, we can make the background task towork in different thread or may be in different server all together . We can make use of celery here. 

  1. Celery - Celery is an asynchronous task/job queue based on distributed message passing .Celery is written in Python, but the protocol can be implemented in any language.
  2. Workers - Used to process the messages sent by Celery. we can set multiple workers.
  3. Supervisor - It is a client/server system that allows its users to monitor and control a number of processes on UNIX-like operating systems. We can start/ stop Celery using this.
  4. Broker - We have to  run  some broker in some server to process our tasks. We can use RabitMQ or Redis for this

Monitoring

When our project is hosted, we need to monitor it using some tools to check its performance, its error logs and  user interactions.We have some tools available for this.

Graphite - Graphite provides real-time visualization and storage of numeric time-series data on an enterprise level.
Statsd - A network daemon that runs on the Node.js platform and listens for statistics, like counters and timers, sent over UDP or TCP and sends aggregates to one or more pluggable backend services (e.g.,Graphite).
Sentry - logging -  Sentry is a modern error logging and aggregation platform.
New Relic - A software analytics tool suite used by developers, ops, and software companies to understand how your applications are performing in development and production.

Deployment automation

Our live project definitely needs continuous development and deployment. So, we definitely need some deployment automation tool that simplifies our deployment. 
On of them is Fabric - Fabric is a Python (2.5-2.7) library and command-line tool for streamlining the use of SSH for application deployment or systems administration tasks.

 

There are some deployment checklists which Django mentions in their docs.
 

https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/. You need to go through this before you host your project to production server.
 http://www.djangobook.com/en/2.0/chapter12.html is another valuable link that mentions deployment and server scaling in django book. 

Subscribe to our newsletter. Get updates on awesome happenings in the technology world!
Newsletter subscription successfull! Something went wrong! Email is already registered!

TAGS