I'm looking to run some Django sites on my VPS, with nginx acting as a front-end for it. I've been having some issues with mod_python and Apache, the site just starts erroring out whenever the traffic starts to pick up because it just uses so much RAM for each request. So I did some research, and found out that mod_pythonreally isn't my best bet for a small VPS.

My setup has nginx serving static files (javascript, css, images) and using memcached to drastically cut down on requests made to an Apache back-end by caching the pages that Apache "makes," but this is still running mod_python, and yesterday I still had some people saying they were getting 500 errors for no reason at all.

What I'm looking to do is use FastCGI to run Django now, I've read that it can handle higher traffic with less RAM, but the configuration of it has been a bit weird for me to understand; I'm no expert on some of the terms being thrown around at all. The main things I'm looking at are these options:

maxspare=NUMBER      max number of spare processes / threads  
minspare=NUMBER      min number of spare processes / threads  
maxchildren=NUMBER   hard limit number of processes / threads  
method=IMPL          prefork or threaded (default prefork)

Any help in determining what I should set these to would be greatly appreciated. I'd also like to know how/if these processes it's mentioning are related to the nginx worker processes. The server hosts 4 websites that usually handle a couple thousand hits per day, but they all tend to get hit around the same time with the majority of the traffic, and that's when issues start.

Also, I read somewhere about using Tornado as a WSGI server for Django... could this possibly be a better solution? Thanks!

  • 1
    For the benefit of others, link to description of why mod_python can cause problems on memory constrained VPS, is 'blog.dscpl.com.au/2009/03/…'. You appear not to be considering one option mentioned in that. – Graham Dumpleton Dec 7 '09 at 0:14

I know this is an old question, but just in case anyone else comes accross this - the recommended way to setup Django on apache these days is to use mod_wsgi:

Deploying Django with Apache and mod_wsgi is the recommended way to get Django into production.

mod_wsgi is an Apache module which can be used to host any Python application which supports the Python WSGI interface, including Django. Django will work with any version of Apache which supports mod_wsgi.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.