On Sep 28, 2005, at 2:48 PM, Jakub Labath wrote:
1. No it doesn't have to be external web server.

However, if you have the resources, it really should be another server -- or at least another instance of Apache running on the same server.

Why? In case you hadn't noticed, Django has a pretty large memory footprint; between Apache, mod_python, Python, the database drivers, etc., Apache server processes tend to weigh about 10M each (at least on my servers). Unfortunately, Apache reuses processes these server processes for a certain number of requests (see the MaxRequestsPerChild directive), but although the server processes grow their memory footprint to accommodate Django, they never shrink.

This means that the same processes that serve your dynamic Django pages are also serving your static files, and thus you're wasting RAM at a prodigious rate. A stripped down Apache that's just serving media files can easily be 10 times faster than one that's also serving dynamic requests, and smaller HTTP servers (lighttpd, tux) can do even better. Case in point: when we moved our media from an Apache vhost in the same instance as our Django server to a separate box running a stripped down lighttpd setup, our media serving got almost 100 times faster.

So, again, if you've got the resources, it's *definitely* worth your time to serve your static files from a different server. Even if you don't I'd make sure that all your media is at least served from a separate subdomain (media.example.com) so that in the future you can move to a dedicated media server should you find the need to scale.

Jacob

Reply via email to