3

I'm writing a small app in Django that will be used as admin interface for a set of applications usually configured by text files. It won't do much (parse user input, convert db entries into flat files and display pretty tables with info) and most likely will be used at most by one user at a time.

Only constraint is that the server it will be run on is low-specced (Pentium M 1,8GHz, 512MB RAM) and I want most of its computing power available for managed apps and not management interface. For the record, I'm using CentOS 5.

What webserver can I use? So far, I gathered following options and opinions:

  • Apache may be to big for this kind of deployment
  • lighttpd + FCGI - may be unstable
  • lighttpd/nginx as rev proxy + django web server - looks strange to me, as I've thought that django web server is meant for development/debugging purposes

Can you recommend me a good solution for this kind of environment? I'm not focused on big workloads or concurrency (as most people asking similar questions are), I just want it to use as little RAM and CPU time as possible when idle or for single sessions.

Additionally, please note, that I don't have much experience in deployments of web servers, reverse proxies etc. (although I know the basics and can find my way around with google), so I would really appreciate help from people who have experience with this kind of problems.

galo
  • 153
  • 4

5 Answers5

4

One of the easiest solutions to setup that performs considerably well in my opinion is nginx along with gunicorn.

For ''gunicorn'', you only need to do something like:

$ cd path/to/yourdjangoproject
$ gunicorn_django --workers=4

And a pretty standard nginx setup for this is

server {
    ...

    location / {
        proxy_pass http://127.0.0.1:8000;
        break;
    }
}

Certainly better than using fcgi and depending on flup but if you don't mind getting your hand's dirty I'd suggest that you try nginx+uwsgi as zaub3r3r suggested.

fim
  • 497
  • 2
  • 5
  • I up-voted this one due to the fact that gunicorn will the best easiest way for you to get a django site up and running. It's certainly not the fastest and @fim did the correct thing with making the workers more then 1. I would go with this solution. – Mike Jun 24 '11 at 12:08
  • Probably I'm going to try gunicorn+nginx, but most likely, I'll test other alternatives (nginx+uwsgi and apache) as well. Thanks! – galo Jun 27 '11 at 12:17
2

Considering your lack of experience and its magnificent management GUI, I recommend Cherokee. A fast, easy to use web server with a built-in wizard for configuring a Django project.

wzzrd
  • 10,269
  • 2
  • 32
  • 47
1

Use Apache and disable the modules you don't need and ensure that you're not spawning too many processes to begin with.

The idea that Apache's core is somehow heavyweight is somewhat of a myth - it can be as beefy or lightweight as you need it to be, thanks to the modular design.

This has the added benefit of working with your existing distribution packaging and update system.

PS: The OS will happily swap out unused pages to disk when the applications are running but the webserver's admin interface is not being accessed. Trust the OS to keep resident what it needs, when it needs it.

PPS: A 2GB DIMM costs less than your time spent typing this inquiry. Take some time to do some meta-analysis of your question.

sneak
  • 178
  • 7
  • 1
    To add to this. It would be important to use worker MPM in Apache. It is use of prefork MPM that causes many memory problems. The worker MPM should then be configured with a single process for original use case. That way you get Django running in only one process. – Graham Dumpleton Jun 25 '11 at 07:18
  • Thanks for the comment. As for the PPS, unfortunately I'm working with fixed system on a cPCI board so I don't hava a choice at the moment. – galo Jun 27 '11 at 10:48
0

The non plus ultra solution , in my eyes, is nginx+uwsgi (it's a bit more difficult to set up, because you have to compile it on your own and config more). The easiest and recommended is Apache+mod_wsgi. I think a well configured Apache2 with mod_wsgi is the right choice for you.

zaub3r3r
  • 900
  • 7
  • 9
0

Django (Python) + webserver? Then maybe have a look at Tornado too (though it can handle far more than you want).

Henk
  • 1,321
  • 11
  • 24