mod_wsgi¶
mod_wsgi is an Apache HTTP Server module for running Python web software compatible with the Web Server Gateway Interface (PEP 333). A mod_wsgi application as created with the control panel provides an Apache HTTP Server with the mod_wsgi module.
Reducing mod_wsgi Memory Consumption¶
mod_wsgi applications can be tuned to consume more or less memory. These strategies may help reduce your mod_wsgi-based application’s memory consumption, but note that some configuration changes may have a negative impact on overall performance. You may want to experiment with different combinations of configuration values to suit your memory and performance needs.
Use the WSGIDaemonProcess directive’s processes setting conservatively: Configure mod_wsgi to start fewer processes by setting a conservative value for the WSGIDaemonProcess directive’s process setting.
In ~/webapps/application/apache2/conf/httpd.conf, where application is the name of the mod_wsgi-based application, edit this line:
WSGIDaemonProcess <app> processes=<num> python-path=/home/<user>/webapps/<app>:/home/<user>/webapps/<app>/lib/python2.7 threads=1where:
- <app> is the name of the mod_wsgi-based application,
- <num> is the number of allowed processes, and
- <user> is your account name,
such that <num> is an integer. For example configuration, two to five processes will be enough for a Django site that uses a separate application to serve static media.
Use the WSGIDaemonProcess directive’s maximum-requests setting: If the application is not releasing memory in a way that’s beyond your control (for example, a library used by your application is leaking memory), then configure the mod_wsgi-based application to serve fewer requests before stopping and replacing a child process.
In ~/webapps/application/apache2/conf/httpd.conf, where application is the name of the mod_wsgi-based application, edit this line:
WSGIDaemonProcess <app> processes=5 python-path=/home/<user>/webapps/<app>:/home/<user>/webapps/<app>/lib/python2.7 threads=1 maximum-requests=<num>where:
- <app> is the name of the mod_wsgi-based application,
- <num> is the maximum number of requests, and
- <user> is your account name,
such that <num> is an integer. Reasonable values are typically between 100 and 1000 requests, though you may need to experiment to find an appropriate setting for your application.
See also
