jvandal / modwsgi

Automatically exported from code.google.com/p/modwsgi
0 stars 0 forks source link

mod_wsgi leaks memory on apache graceful restart #162

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. enable mod_wsgi in apache
2. gracefully restart apache
3. check ps output for process size

I expect apache's size to remain constant after it settles, not continually
grow. 

I am on CentOS Linux 5
[root@miketug2 ~]# uname -a
Linux miketug2 2.6.18-164.el5PAE #1 SMP Thu Sep 3 04:10:44 EDT 2009 i686
i686 i386 GNU/Linux
[root@miketug2 ~]# rpm -q httpd
httpd-2.2.3-31.el5.centos
[root@miketug2 ~]# rpm -q python
python-2.4.3-27.el5
[root@miketug2 ~]# rpm -q mod_wsgi
mod_wsgi-2.6-1

Original issue reported on code.google.com by msoul...@gmail.com on 23 Oct 2009 at 3:40

GoogleCodeExporter commented 8 years ago
Leak test

[root@miketug2 teleworker]# grep -i python /etc/httpd/admin-conf/httpd.conf
[root@miketug2 teleworker]# sv term /service/httpd-admin/
[root@miketug2 teleworker]# ps -eo pid,user,fname,vsize --sort -vsize | grep 
httpd-ad
25737 admin    httpd-ad  15284
25736 root     httpd-ad  11960
[root@miketug2 teleworker]# ps -eo pid,user,fname,vsize --sort -vsize | grep 
httpd-ad
25737 admin    httpd-ad  15284
25736 root     httpd-ad  11960
[root@miketug2 teleworker]# sv 1 /service/httpd-admin
[root@miketug2 teleworker]# ps -eo pid,user,fname,vsize --sort -vsize | grep 
httpd-ad
25746 admin    httpd-ad  16140
25736 root     httpd-ad  12816
[root@miketug2 teleworker]# sv 1 /service/httpd-admin                          
[root@miketug2 teleworker]# ps -eo pid,user,fname,vsize --sort -vsize | grep 
httpd-ad
25751 admin    httpd-ad  16976
25736 root     httpd-ad  13652
[root@miketug2 teleworker]# sv 1 /service/httpd-admin                          
[root@miketug2 teleworker]# ps -eo pid,user,fname,vsize --sort -vsize | grep 
httpd-ad
25755 admin    httpd-ad  17812
25736 root     httpd-ad  14488

Original comment by msoul...@gmail.com on 23 Oct 2009 at 3:42

GoogleCodeExporter commented 8 years ago
Read response to:

http://groups.google.com/group/modwsgi/browse_frm/thread/68c11ce66d9691bf

Should be using at least mod_wsgi 2.4 to eliminate primary problem and mustn't 
be using mod_python at 
same time.

Further changes done in mod_wsgi 3.0 to eliminate totally problems resulting 
from Python interpreter itself 
leaking memory.

Original comment by Graham.Dumpleton@gmail.com on 24 Oct 2009 at 2:44

GoogleCodeExporter commented 8 years ago

Original comment by Graham.Dumpleton@gmail.com on 24 Oct 2009 at 2:46

GoogleCodeExporter commented 8 years ago
If you look at my original report above, I'm using mod_wsgi 2.6, and I'm not 
using
mod_python, and it's still leaking. Is it my version of Python?

Original comment by msoul...@gmail.com on 24 Oct 2009 at 3:44

GoogleCodeExporter commented 8 years ago
On the list you stated you were using:

[root@miketug2 teleworker]# rpm -q mod_wsgi 
mod_wsgi-2.1-2.el5 

Ie., older version.

As I said on list Python itself also leaks memory with some versions, some 
versions worse than others.

I didn't pick up that you were quoting different version here.

Same issues as described on list and in references in the list mails apply.

Original comment by Graham.Dumpleton@gmail.com on 24 Oct 2009 at 5:36

GoogleCodeExporter commented 8 years ago
I tried both, to see if the issue was fixed in the latest release. It did not 
appear
to be, but CentOS is still using Python 2.4.

Original comment by msoul...@gmail.com on 24 Oct 2009 at 3:01

GoogleCodeExporter commented 8 years ago
If by both you mean mod_wsgi 2.6 and mod_wsgi 3.0c5, and for 3.0c5 you ensured 
you set 
WSGILazyInitialization directive to On and you are not still loading mod_python 
at the same time, then I would 
suggest it is not a mod_wsgi issue at all.

Have you tried disabling both mod_wsgi and mod_python completely, not even 
loading the modules in Apache, 
and then see if Apache itself is leaking memory on a restart.

As was mentioned on the list, mod_ssl in some situations leaks memory, perhaps 
dependent on version of 
Apache and APR being used. Thus other Apache modules aren't immune to memory 
leaks.

In short, if using 3.0c5 and you have managed to correctly enable lazy 
initialisation, there simply is not way that 
Python can leak into parent Apache process and there are no other known issues 
with mod_wsgi leaking memory 
ever.

To investigate it any further, I would need you to have et:

  LogLevel info

in Apache configuration and post up the error logs showing all the messages 
produced by mod_wsgi on startup 
so can confirm whether you are in fact using lazy initialisation or not.

Original comment by Graham.Dumpleton@gmail.com on 25 Oct 2009 at 2:09

GoogleCodeExporter commented 8 years ago
I guess WSGILazyInitialization isn't supported in 2.6.

I guess the option is not supported in 2.6, which is the latest stable release. 

[root@miketug2 httpd-admin]# ./run
Syntax error on line 185 of /etc/httpd/admin-conf/httpd.conf:
Invalid command 'WSGILazyInitialization', perhaps misspelled or defined by a 
module
not included in the server configuration

[root@miketug2 httpd-admin]# rpm -q mod_wsgi
mod_wsgi-2.6-1

No, by both I meant the originally reported mod_wsgi 2.1, and 2.6 which I built 
and
tested afterwards.

I guess I can try 3.0rc5.

Original comment by msoul...@gmail.com on 26 Oct 2009 at 1:45

GoogleCodeExporter commented 8 years ago
Correct, lazy initialisation is only implemented from 3.0 onwards and for 3.0c5 
has to be enabled explicitly for 
Python 2.X, whereas from next release candidate it will be on by default for 
both Python 2.X and 3.X.

Original comment by Graham.Dumpleton@gmail.com on 27 Oct 2009 at 12:00