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 application’s memory consumption, but note that some configuration changes may degrade overall performance. Experiment with different combinations of configuration values to suit your memory and performance needs.

  • Use the WSGIDaemonProcess directive’s processes setting conservatively: Start fewer processes by setting a small 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=1
    

    where:

    • <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, 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 an 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 mod_wsgi 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.

Previous topic

Mercurial

Next topic

MongoDB

Search the documentation

Example: "configure email" or "create database"

Feedback

Send us your feedback on this documentation.