On Oct 11, 9:23 am, mguthrie <mitchguth...@gmail.com
> I had read in more than one place that a django instance can eat up to
> 10mb - 30mb of memory. I don't know whether that is fact or fiction
> and I'm also confused by the term instance. Is an instance defined as
> multiple different Django projects or a single Django project used
> multiple times? If it is true that one Django project used across
> multiple <Location>'s eats up that much memory I wouldn't able able to
> host very many clients on a server.
> I'm trying to devise my infrastructure ahead of time so I'm not stuck
> with a finished application that can't be hosted for many clients.
The comment by Colin about use of multiple sub interpreters not
requiring much more memory is true, but misleading. This is because as
you suspect the main issue is how much Django itself takes and not the
overhead of mod_python or Python sub interpreters.
The problem with using mod_python is that Django instances run in sub
interpreters of Apache child worker processes, thus, how much overall
memory used is in part dictated by which Apache MPM you are using and
how many processes Apache has been configured to use. To clarify,
Apache on UNIX is a multiprocess web server. Thus there isn't just one
instance of Django per site, but number of Apache child worker
processes multiplied by the number of sites.
If you are are using Apache prefork MPM, it is not uncommon to use a
configuration that sees minimum 10-20 processes and maximum of 100.
Thus, if you had 5 sites each running at minimal 20MB, worst case
where Apache had to create maximum number of processes to handle load,
would be 5*20*100 MB. A lot of Django sites run with lot more memory
Using Apache worker MPM, where each Apache child worker process is
multithreaded can be better, as in that case configuration would
normally see maximum of 5-10 processes. So, maximum would be 5*20*10
MB, which is a lot less.
To use Apache worker MPM though, you would need to use Django 1.0 as
older versions had some question marks over their readiness for
multithreaded use. Your application itself would also need to
Now, for another option, you may want to use mod_wsgi instead. Whether
you use Apache prefork or worker MPM, with mod_wsgi you would create a
daemon process group for each site and delegate specific WSGI
applications for each site to run in their own daemon group processes.
Using daemon mode gives various benefits. These are they each site
runs in its own processes and no risk of each interfering with each
other. Each site can run as a distinct user. Individual sites can be
restarted without restarting whole of Apache. And the number of
processes used by each site can be be better controlled, with it being
independent of MPM used and how many Apache child worker processes
In summary, if you need to be mindful of memory usage, you would be
better of using mod_wsgi and its daemon mode. This is because it gives
you separate control over number of processes in use for each site and
number of processes fixed and isn't variable based on load and Apache
making a decision to create more worker processes.
Note that mod_wsgi and daemon mode doesn't preclude you still running
a site within embedded mode, ie., in Apache child worker processes, at
the same time if you feel that the bit of extra speed coming from
embedded mode is important to you for a specific site.
> > > Django instance or multiple? Ismod_pythonnot the way to go for this