When a process is freshly started and as requests come in, it is not uncommon for Python web application memory growth to grow with each request. If everything is okay it should plateau over time. This is partly to do with the lazy loading of code by a Python web application, but also result of caching of data for views, plus generally how Python manages objects and garbage collection.
The issue will be if the memory just keeps going up continually. This sort of problem can be caused by various issues in your code, including Python object reference count cycles involving objects with __del__ methods, resulting in objects not being able to be deleted properly. Could also be incorrect use of caches in Django. First up you need to work out for sure that memory use doesn’t plateau over time. What version of mod_wsgi are you using? Graham > On 1 Dec 2016, at 3:02 AM, Divick Kishore <[email protected]> wrote: > > Hi, > I am trying to use mod_wsgi with apache for running django apps and for > some reason the memory usage keeps increasing. I am running django with > DEBUG=False and my http.conf looks something like the following: To keep > things simple I have set the apache workers to 1 as well as apache worker > threads to 1 and also wsgi threads to 1. > > > ServerRoot "/home/myproj/webapps/myproj_test/apache2" > > LoadModule authz_core_module modules/mod_authz_core.so > LoadModule dir_module modules/mod_dir.so > LoadModule env_module modules/mod_env.so > LoadModule log_config_module modules/mod_log_config.so > LoadModule mime_module modules/mod_mime.so > LoadModule rewrite_module modules/mod_rewrite.so > LoadModule setenvif_module modules/mod_setenvif.so > LoadModule wsgi_module modules/mod_wsgi.so > LoadModule unixd_module modules/mod_unixd.so > LoadModule access_compat_module modules/mod_access_compat.so > LoadModule authz_host_module modules/mod_authz_host.so > LoadModule info_module modules/mod_info.so > LoadModule status_module modules/mod_status.so > > LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" > \"%{User-Agent}i\"" combined > > Listen 25459 > KeepAlive Off > SetEnvIf X-Forwarded-SSL on HTTPS=1 > ServerLimit 1 > StartServers 1 > MaxRequestWorkers 1 > MinSpareThreads 1 > MaxSpareThreads 1 > ThreadsPerChild 1 > > RewriteEngine on > > WSGIRestrictEmbedded On > WSGILazyInitialization On > WSGIPassAuthorization On > > WSGIPythonPath > /home/myproj/webapps/myproj_test:/home/myproj/webapps/myproj_test/myproj:/home/myproj/webapps/myproj_test/lib/python2.7 > > <VirtualHost *> > ServerName test.myproj.io > > CustomLog /home/myproj/logs/user/myproj_test/access_myproj_test.log combined > ErrorLog /home/myproj/logs/user/myproj_test/error_myproj_test.log > > RewriteCond %{REQUEST_URI} ^/$ [NC] > RewriteRule ^(.*)$ /home/myproj/webapps/myproj_test_static/index.html [L] > > RewriteCond %{REQUEST_URI} ^/static/$ [NC] > RewriteRule ^/static/(.*)$ /home/myproj/webapps/myproj_test_static/$1 [L] > > <Location /server-status> > SetHandler server-status > > Order Deny,Allow > Allow from all > </Location> > > <Location /server-info> > SetHandler server-info > > Order Deny,Allow > Allow from all > </Location> > > WSGIDaemonProcess myproj_test threads=1 display-name=mod_wsgi > python-path=/home/myproj/webapps/myproj_test:/home/myproj/webapps/myproj_test/myproj:/home/myproj/webapps/myproj_test/lib/python2.7:/home/myproj/webapps/myproj_test/.ve/lib/python2.7/site-packages > WSGIProcessGroup myproj_test > WSGIScriptAlias / /home/myproj/webapps/myproj_test/myproj/myproj/wsgi.py > </VirtualHost> > > > I am running apache with supervisord using the following > configuration/command line: > > command=/home/company/webapps/myproj_test/apache2/bin/httpd.worker -f > /home/company/webapps/myproj_test/apache2/conf/httpd.conf -D FOREGROUND -k > start > > and when I look at the resident memory size using htop, I see that with every > request the memory keeps increasing. In my views there are some calls which > really do no nothing and still the memory keeps increasing for every request. > Could someone please help what is wrong? Is my apache configuration an issue > or there is something else altogether. > > In case it helps, I am running Django 1.8.1 on webfaction. > > Thanks, > Divick > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/modwsgi > <https://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
