views:

529

answers:

4

Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.

Long version: I'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better "deployment" of Django.

Currently I'm using Django through Tornado's WSGI interface with an nginx front-end on Debian Lenny. I'm looking to move into the Rackspace Cloud so I've been given quite a few choices when it comes to OS:

  • Debian 5.0 (Lenny)
  • FC 11 or 12
  • Ubuntu 9.10 or 8.04 (LTS)
  • CentOS 5.4
  • Gentoo 10.1
  • Arch Linux 2009.02

What I've gathered is this:

Linux Distributions

Debian and CentOS are very slow to release non-bugfix updates of software, since they focus mainly on stability. Is this good or bad? I can see stability being a good thing, but the fact that I can't get Python 2.6 without quite a headache of replacing Python 2.4 is kind of a turn-off--and if I do, then I'm stuck when it comes to ever hoping to use apt/yum to install a Python library (it'll try to reinstall Python 2.4).

Ubuntu and Fedora seem very... ready to go. Almost too ready to go, it's like everything it already done. I like to tinker with things and I prefer to know what's installed and how it's configured versus hitting the ground running with a "cookie-cutter" setup (no offense intended, it's just the best way to describe what I'm trying to say). I've been playing around with Fedora and I was pleasently surprised to find that pycurl, simplejson and a bunch of other libraries were already installed; that raised the question, though, what else is installed? I run a tight ship on a very small VPS, I prefer to run only what I need.

Then there's Gentoo... I've managed to install Gentoo on my desktop (took a week, almost) and ended up throwing it out after quite a few events where I wanted to do something and had to spend 45 minutes recompiling software with new USE flags so I can parse PNG's through PIL. I've wondered though, is Gentoo good for something "static" like a server? I know exactly what I'm going to be doing on my server, so USE flags will change next to never. It optimizes compiles to fit the needs of what you tell it to, and nothing more--something I could appreciate running on minimal RAM and HDD space. I've heard, though, that Gentoo has a tendency to break when you attempt to update the software on it... that more than anything else has kept me away from it for now.

I don't know anything about Arch Linux. Any opinions on this distro would be appreciated.

Web Server

I've been using Tornado and I can safely say it's been the biggest hassle to get running. I had to write my own script to prefork it since, at the time I setup this server, I was probably around 10% of Tornado's user-base (not counting FriendFeed). I have to then setup another "watchdog" program to make sure those forks don't misbehave. The good part is, though, it uses around 40MB of RAM to run all 7 of my Django powered sites; I liked that, I liked that a lot.

I've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it.

There's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache/mod_python isn't even an option, as I have very limited RAM.

Segue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though.

What I'm looking for is what you have seen as the "best" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.

+3  A: 
  1. Update your question to remove the choices that don't work. If it has Python 2.4, and an installation is a headache, just take it off the list, and update the question to list the real candidates. Only list the ones that actually fit your requirements. (You don't say what your requirements are, but minimal upgrades appears to be important.)

  2. Toss a coin.

When choosing between two platforms which meet your requirements (which you haven't identified) tossing a coin is the absolute best way to choose.

If you're not sure if something matches your requirements, it's often good to enumerate what you value. So far, the only thing in the question that you seem to value is "no installations". Beyond that, I can only guess at what requirements you actually have.

Once you've identified the set of features you're looking for, feel free to toss a coin.

Note that Linux distributions all have more-or-less the same open-source code base. Choosing among them is a preference for packaging, support and selection of pre-integrated elements of the existing Linux code base. Just toss a coin.

Choosing among web front-ends is entirely a question of what features you require. Find all the web front-ends that meet your requirements and toss a coin to choose among them.

None of these are "lock-in" decisions. If you don't like the linux distro you chose initially, you can simply chose another. They all have the same basic suite of apps and the same API's. The choice is merely a matter of preference.

Don't like the web server you chose? At the end of the mod_wsgi pipe, they all appear the same to your Django app (plus or minus a few config changes). Don't like lighttpd? Switch to nginx or Apache -- your Django app doesn't change. So there's no lock-in and no negative consequences to making a sub-optimal choice.

When there's no down-side risk, just toss a coin.

S.Lott
I'm looking for a web server that's light on RAM, can support upstream servers and can support VHosts. Nginx works very well for this; I'll have to give Lighttpd a try; I've only had bad experiences with Apache - with mod_python, though.
Zack
+3  A: 

At the place I rent server, they have shaved down the Ubuntu images to bare minimum. Presumably because they had to make a special image anyway with just the right drivers and such in it, but I don't know exactly. They have even removed wget and nano. So you get all the apt-get goodness and not a whole lot of "cookie-cutter" OS.

Just saying this because I would imagine that this is the way it is done almost everywhere and therefore playing around with a normal Ubuntu-server install will not provide you with the right information to make your decision.

Other than that, I agree with the others, that it is not much of a lock-in so you could just try something.

On the webserver-side I would suggest taking a look at cherokee, if have not done so already. It might not be your cup of joe, but there is no harm in trying it. I prefer the easy setup of both Ubuntu and Cherokee. Although I play around with a lot of things for fun, I prefer these for my business. I have other things to do than manage servers, so any solution that helps me do it faster, is just good. If these projects are mostly for fun then this will most likely not apply since you won't get a whole lot of experience from these easy-setup-with-nice-gui-and-very-helpfull-wizards

Mathias Nielsen
I've yet to try Cherokee, but I'll give it a try and see how well it works. I can handle pretty much any amount of configuration, that just comes easily to me, but it's the whole... deciding thing that I have trouble with. Thanks for your input :)
Zack
+1  A: 

If you want a lightweight alternative to Tornado, I'd suggest spawning. It's very good at code reloading and seems to have good performance - though of course best you try it out yourself.

I'd also recommend supervisord regardless of OS, for keeping Tornado or spawning instances up and running as well as any other essential services.

However 9 times out of 10 it's the database that's the bottleneck and choice of web server is not really going to impact site performance and scalability.

zeemonkee
I usually RAM cache the entire database. Since most of my sites have relatively small DBs that update daily or hourly, invalidating and reloading the cache on save() isn't too hard to pull off. I did use SupervisorD to keep all my Tornado forks running, it worked quite well and was simple to configure. I'll have to give Spawning a look, it might be better for me since I rarely used Tornado for anything but a WSGI server.
Zack
I'll probably be giving Fedora a look. I like the yum package manager (just personal preference) and I saw it had a lot of packages that I wanted (most recent nginx, python, tornado, supervisor, memcached, pycurl, simplejson... there's a looong list). Perhaps being able to install -everything- from a package manager will make my life a lot easier. I'm definitely going to give Spawning a shot, though, I was just reading up on it a bit and it looks interesting... not too sure if I -like- the code reloading. I'll play it by ear, though.
Zack
A: 

Personally I find one of the BSD systems far superior to Linux distros for server related tasks. Give OpenBSD or perhaps FreeBSD a chance. Once you do you´ll never go back.

Simon
I'd be willing to try, but my current provider doesn't allow the use of any OS's other than the ones I have listed above.
Zack