mod-wsgi processes are never terminated
I have configured my Apache with mod_wsgi to serve web.py application.
Apache configuration,
(PWPYTHON)ubuntu@PWVM2:~$ apache2 -V
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:37:10
Server's Module Magic Number: 20051115:30
Server loaded: APR 1.4.6, APR-Util 1.3.12
Compiled using: APR 1.4.6, APR-Util 1.3.12
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/prefork"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/apache2"
-D SUEXEC_BIN="/usr/lib/apache2/suexec"
-D DEFAULT_PIDLOG="/var/run/apache2.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="mime.types"
-D SERVER_CONFIG_FILE="apache2.conf"
Now, sample vhost file is,
Listen 20109
<VirtualHost *:20109>
DocumentRoot /
WSGIScriptAlias / /server.py
WSGIDaemonProcess egauge user=ubuntu group=ubuntu processes=3 threads=3
home=/ maximum-requests=1000 shutdown-timeout=10 display-name=rs-egauge
WSGIProcessGroup egauge
WSGIApplicationGroup %{GLOBAL}
AddType text/html .py
<Directory />
Order deny,allow
Allow from all
</Directory>
ErrorLog "|/usr/sbin/rotatelogs
/var/log/apache2/rs_egauge_error.log.%Y.%m.%d 86400"
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel info
CustomLog "|/usr/sbin/rotatelogs
/var/log/apache2/rs_egauge_access.log.%Y.%m.%d 86400" pw_rs_combined
</VirtualHost>
As you can see i've mentioned 3 processes and 3 threads in daemon mode.
Now, when i send 1000's of request after serving some set of requests,
apache should kill the interpreter and reinitiate a new one. Apache tries
to do this, however the killed processes stays back in the memory as
subprocesses of init(PID-1). Thus occupying memory. Eventually number of
processes increases and system crashes due to lack of memory.
So, what can be done to avoid this ? Am i doing anything wrong in
application itself ?
Please help me out.
No comments:
Post a Comment