Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate servers to serve django app and it's content?

I'm a little confused as to how to proceed. I'm setting up Django to run on a Mediatemple DV server. I'm trying to figure out the appropriate setup for serving image/video/etc content.

I don't quite understand what this means on http://docs.djangoproject.com/en/dev/howto/deployment/modwsgi/

We recommend using a separate Web server -- i.e., one that's not also running Django -- for serving media. Here are some good choices:

lighttpd, Nginx, TUX, A stripped-down version of Apache, Cherokee

Does this mean I should serve Django on one Apache instance (via mod_wsgi) and then serve its content on another instance of Apache or one of the alternatives above? I can do this on the same dedicated virtual server, right? If so, any advice on how I should do that?

Thanks!

like image 575
pcpc33 Avatar asked Apr 05 '11 19:04

pcpc33


People also ask

Which server to use with Django?

Gunicorn is the recommended HTTP server for use with Django on Heroku (as referenced in the Procfile above). It is a pure-Python HTTP server for WSGI applications that can run multiple Python concurrent processes within a single dyno (see Deploying Python applications with Gunicorn for more information).

Does Django need an application server?

Django, being a web framework, needs a web server in order to operate. And since most web servers don't natively speak Python, we need an interface to make that communication happen.

Is Django a server?

Django is an extremely popular and fully featured server-side web framework, written in Python. This module shows you why Django is one of the most popular web server frameworks, how to set up a development environment, and how to start using it to create your own web applications.


1 Answers

For the majority of people there is no need for a separate media server. There has been growing criticism over the Django documentation being too liberal in pushing people in that direction when there is no need.

So, don't bother initially and if using mod_wsgi use the the Apache web server for static media as well. It is recommended though that you ensure your run your WSGI application in daemon mode of mod_wsgi as that way the processes serving up static files will be slim and not incur overhead of the actual dynamic web application.

If overly worried about memory usage, also have a read of:

http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html

See how that all goes and only when Apache itself looks not to be enough, then look to using another server to handle media, the preferred arrangement being to use nginx to handle static media, with nginx also acting as proxy through to Apache/mod_wsgi. Using nginx in front actually allows Apache/mod_wsgi to perform better, which using nginx on a separate domain will not.

like image 55
Graham Dumpleton Avatar answered Oct 09 '22 18:10

Graham Dumpleton