You are here: Home Articles Update - Repoze under mod_wsgi is not slow
Navigation
OpenID Log in

 

Update - Repoze under mod_wsgi is not slow

by Martin Aspeli last modified May 06, 2008 09:09 PM

It helps to know what you're doing!

In my previous blog post, I noted that running a site under mod_wsgi via Repoze was causing intermittent slowness. Graham Dumpleton, the author of mod_wsgi, kindly send me an email to explain how I should be doing things. I've corrected the post, and the site is now just as fast as a regular Plone site.

Below is an edited version of Graham's email, containing some interesting details:

"Your performance issues with mod_wsgi are most likely due to it running in embedded mode when you thought it was running in daemon mode.

The configuration you had was:

WSGIDaemonProcess photoblog threads=1 maximum-requests=10000 processes=4 python-path=/usr/lib/python2.4/site-packages

<VirtualHost 89.250.115.180:80>
    ServerName domain.com
    ServerAlias www.domain.com
    WSGIScriptAlias / /home/optilude/sites/photoblog/bin/zope.wsgi
    WSGIApplicationGroup photoblog
    WSGIPassAuthorization On
    SetEnv DISABLE_PTS 1
    SetEnv HTTP_X_VHM_HOST http://domain.com
    SetEnv HTTP_X_VHM_ROOT /blog
    SetEnv APP_NAME blog
</VirtualHost>

<VirtualHost 89.250.115.180:80>
    ServerName admin.domain.com
    WSGIScriptAlias / /home/optilude/sites/photoblog/bin/zope.wsgi
    WSGIApplicationGroup photoblog
    WSGIPassAuthorization On
    SetEnv DISABLE_PTS 1
    SetEnv HTTP_X_VHM_HOST http://admin.domain.com
    SetEnv HTTP_X_VHM_ROOT /blog
    SetEnv APP_NAME zope
</VirtualHost>


You probably want:

WSGIDaemonProcess photoblog threads=1 maximum-requests=10000 processes=4 python-path=/usr/lib/python2.4/site-packages

<VirtualHost 89.250.115.180:80>
    ServerName domain.com
    ServerAlias www.domain.com
    WSGIScriptAlias / /home/optilude/sites/photoblog/bin/zope.wsgi

    # XXX
    WSGIProessGroup photoblog
    WSGIApplicationGroup %{GLOBAL}
    # XXX

    WSGIPassAuthorization On
    SetEnv DISABLE_PTS 1
    SetEnv HTTP_X_VHM_HOST http://domain.com
    SetEnv HTTP_X_VHM_ROOT /blog
    SetEnv APP_NAME blog
</VirtualHost>

<VirtualHost 89.250.115.180:80>
    ServerName admin.domain.com
    WSGIScriptAlias / /home/optilude/sites/photoblog/bin/zope.wsgi

    # XXX
    WSGIProcessGroup photoblog
    WSGIApplicationGroup %{GLOBAL}
    # XXX

    WSGIPassAuthorization On
    SetEnv DISABLE_PTS 1
    SetEnv HTTP_X_VHM_HOST http://admin.domain.com
    SetEnv HTTP_X_VHM_ROOT /blog
    SetEnv APP_NAME zope
</VirtualHost>


That is WSGIProcessGroup directive should be used to delegate to mod_wsgi daemon process group. The WSGIApplicationGroup is used to optionally control what Python sub interpreter instance within a process is used.

You probably still want WSGIApplicationGroup, because you appear to want to run both sites in same Python sub interpreter under virtual host monster to cut down on space. By setting application group to %{GLOBAL}, they will run in first interpreter that Python creates in process when initialised, thus don't waste space in creating extra interpreters. Using first interpreter also means you avoid problems with third party C extension modules that don't like running in secondary sub interpreters.

With the configuration you had, Apache child process would have been used instead and each would have had a copy of your Zope application, and although you might not have had MaxRequestsPerChild for Apache child processes set, because Apache can dynamically create additional child processes to meet demand, the delays you saw at odd times could have been due to that. When Apache thought the child processes were no longer required it would have killed off any extras, thus next time it thinks it needs more, has to create more and thus go load Zope all over again."

Document Actions
Plone Book
Professional Plone 4 Development

I am the author of a book called Professional Plone Development. You can read more about it here.

About this site

This Plone site is kindly hosted by: 

Six Feet Up