On Jul 21, 8:18 am, mdipierro <
mdipie...@cs.depaul.edu> wrote:
> Can you comment on memory usage?
>
> I have see this once: "after a while web serving slows"
> it appeared to be due to a memory leak somewhere (did not experience
> it with web2py+Rocket but only in web2py+mod_wsgi+apache).
>
> I googled it and I found Django was having the same problem on some
> hosts:
Not sure how you can draw a parallel to that as it is a completely
different framework and just because another framework, or more
specifically one persons code, has issues, doesn't imply there is an
issue with underlying web hosting.
These sorts of problems are isolated cases. If there was an issue with
memory leakage in the hosting mechanism it would be affecting everyone
and there have been no such reports of mod_wsgi itself leaking memory.
That said, ensure you read:
http://blog.dscpl.com.au/2009/11/save-on-memory-with-modwsgi-30.html
This describes how Python itself leaks memory. For mod_wsgi 2.X and
older, or if you are still loading mod_python into your Apache server,
then you can be affected by this, but not if using mod_wsgi 3.X.
That post also explains how to completely disable initialisation of
Python in Apache server child processes, ie., embedded, if you aren't
using it.
>
http://stackoverflow.com/questions/2293333/django-memory-usage-going-...http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory...
>
> I followed the advice from a comment in the last post to limit the
> number of requests served by each process:
Which is actually a useless thing to do if you are using daemon mode
which I understood you were, as MaxRequestsPerChild directive only
affects Apache server child process, ie., those use for embedded mode,
and not daemon mode processes.
If using that directive helped and you were using daemon mode, then
you likely have a memory leak in some other Apache module.
What you should have ensured you were doing was using display-name
option to WSGIDaemonProcess to name the process. That way in 'ps' you
can easily distinguish the mod_wsgi daemon mode processes from the
Apache processes and work out which is leaking memory. If it is the
daemon processes, it is likely to be a Python web application issue.
If the Apache parent process is getting fatter and you perform a lot
of Apache restart/reloads, then it could be that you are still using
mod_wsgi 2.X or mod_python is loaded at same time, and you are using a
version of Python that has lots of memory leaks on restarts.
If your daemon processes are not getting fat and the Apache server
child processes are, then you may through incorrect configuration not
even be running Python web application in daemon mode. This is where
WSGIRestrictEmbedded as described in my post is good, as it will
highlight when the configuration is screwed up.
> # prefork MPM
> StartServers 5
> MinSpareServers 5
> MaxSpareServers 10
> MaxClients 256
> MaxRequestsPerChild 500
> ServerLimit 30
>
> instead of the default:
>
> # prefork MPM
> StartServers 5
> MinSpareServers 5
> MaxSpareServers 10
> MaxClients 256
>
> The problem disappeared. The exact values that fix the problem may
> depend on the ram available.
The other difference with above is that I think by setting ServerLimit
to 30, you have effectively overridden MaxClients down to 30 even
though set to 256. You have thus in part limited the exact problems
described in:
http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html
if it so happens you were using embedded mode and not daemon mode.
Graham