I definitely agree that there should be a setup guide / script for
nginx/wsgi for web2py.

That said, I'm not giving up on Apache yet.  I think I found out what
the culprit to this high usage of RAM for Debian squeeze.

Short answer.  I think this will fix it:

sudo apt-get install apache2-mpm-prefork

===
Long answer.  I think it's more complicated that I understand, but my
understanding is that this has to do with how Apache2 handles multi-
processing.  Apparently, there 3 modules related to this: (1) prefork,
(2) worker and (3) event.   You can install each with apt-get (e.g.
apt-get install apache2-mpm-worker or apt-get install apache2-mpm-
event).

I think Debian 6 (squeeze) has "worker" as the default multi-
processing module.

Prefork is the non-threaded, traditional, tried-and-true mode of
Apache2.  Worker is the multithread version and it consumes a lot of
RAM.   Event is based on Worker.  It takes as much memory as Worker,
is experimental and is supposed to work well with applications having
lots of requests.

In my application, Worker consumes lots of RAM, but doesn't appear to
have any benefits.  Event actually produces the best result (the most
number of requests/sec and the lowest time per request), while
consumes as much RAM as Worker.

So, I think if your RAM is abundant, I'd suggest that you try the
apache2-mpm-event module.  If not, try apache2-mpm-prefork module.

========


While I am playing with these modules, I also discovered that with
web2py having more processes is much better than having more threads.
My current configuration of wsgi is processes=5 and threads=1.  This
works much better than for example processes=1 and threads=15 (which I
think is the default configuration).

Massimo might want to play around with this and might want to change
the official Apache guideline to reflect this.

========

With prefork, 5 processes, 1 thread, I'm quite happy.  Things are
quite snappy, and RAM are well under control.

So, until the next headache, there it is.


Reply via email to