Hi Graham,

First off thank you very much for the support you have given, I really 
appreciate the time you've taken to help me. I read over the changes you 
kindly pointed out and have now amended the virtual host file to use the 
following configuration.

*virtual host file*
WSGIRestrictEmbedded On
<VirtualHost *:80>

...

WSGIPassAuthorization On

    WSGIDaemonProcess xxx.com user=django group=admin processes=2 threads=2 
display-name=xxx.com python-home=/srv/django/xxx
    WSGIScriptAlias / /srv/django/xxx.com/xxx/xxx/wsgi.py 
process-group=xxx.com application-group=%{GLOBAL}

    <Directory /srv/django/xxx.com/xxx/>
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>


Once I had this configuration in place I received the following error.

[wsgi:info] [pid 19595:tid 140504746649728] mod_wsgi (pid=19595): Python 
home /srv/django/xxx.com.
[wsgi:info] [pid 19595:tid 140504746649728] mod_wsgi (pid=19595): 
Initializing Python.
ImportError: No module named site

I double checked my installation of mod_wsgi and confirmed that it was 
indeed configured against my alternative installed python version that I 
had wanted and then checked my virtual environment was using the same 
alternative installed Python version and it was. I then decided to pip 
install the mod_wsgi package within the virtual environment and then 
modified the "LoadModules" path for mod_wsgi to that of the virtual 
environments as can be seen below.

LoadModule wsgi_module 
/srv/django/xxx.com/lib/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so

This alleviated the issue of "No module named site" but it still left me 
page load times of roughly ~1 minute upon request.
I restarted the server and waited roughly a minute before requesting a 
page, hoping to verify that the application had loaded into the processes 
by then but instead of seeing a response of 3 seconds or less I got ~1 
minute. This is leaving me to think that the application isn't being loaded 
into the processes until a request has been made whereas I though the 
configuration allowed the application to preload before a request was made?

Is there any where else to look at this point that I may be overlooking, I 
have a feeling that it may be in and around the area that led me to pip 
install mod_wsgi instead of using my source installed version?

Many Thanks,
David

On Saturday, 4 March 2017 22:21:36 UTC, Graham Dumpleton wrote:
>
>
> On 5 Mar 2017, at 7:42 AM, David <[email protected] <javascript:>> wrote:
>
> I've found an issue in heavily increased loading time when mod_wsgi loads 
> the application for the first time. This has started since since upgrading 
> from my old setup of CentOS 6, Python 2.7.5, Apache 2.2.15, and mod_wsgi 
> 3.4 to my new setup of CentOS 7, Python 2.7.13, Apache 2.4.6, and mod_wsgi 
> 4.5.13.
>
> The change has caused the initial loading time of the application into 
> memory from ~5 seconds to ~1 minute. I have followed the "Checking Your 
> Installation" as much as I could, coming up with a blank as to what could 
> be causing this increase.
>
> The mod_wsgi and Apache configuration is the same across both the older 
> and new setup, configured to use the worker mpm module running in daemon 
> mode. Please find the configuration of both the virtualhost file and the 
> worker configuration found in the main httpd.conf file below.
>
> *httpd.conf*
> <IfModule mpm_worker_module>
>     StartServers         16
>     MaxClients           250
>     MinSpareThreads      10
>     MaxSpareThreads      10
>     ThreadsPerChild      25
>     MaxRequestsPerChild  0
> </IfModule>
>
>
> *virtualhost configuration*
>
> WSGISocketPrefix run/wsgi
> WSGILazyInitialization On
>
>
> This is the default, you don't need this directive.
>
> WSGIRestrictEmbedded Off
>
>
> You want to set this to On, not Off.
>
> <VitualHost *:80>
>
>     ...
>
>     WSGIPassAuthorization On
>     WSGIDaemonProcess xxx.com user=django group=admin processes=2 
> threads=2 display-name=xxx.com 
> python-path=/srv/django/xxx/lib/python2.7/site-packages
>
>
> Use:
>
>     WSGIDaemonProcess xxx.com user=django group=admin processes=2 
> threads=2 display-name=xxx.com python-home=/srv/django/xxx
>
> You should not use python-path for setting up a virtual environment, use 
> python-home instead.
>
>     WSGIProcessGroup xxx.com
>
>
> You don't need WSGIProcessGroup if set process-group as option to 
> WSGIScriptAlias. See below.
>
>     WSGIScriptAlias / /srv/django/xxx/xxx/xxx/wsgi.py
>     WSGIImportScript /srv/django/xxx/xxx/xxx/wsgi.py process-group=xxx.com 
> application-group=xxx.com
>
>
> It is better to use:
>
>     WSGIScriptAlias / /srv/django/xxx/xxx/xxx/wsgi.py process-group=
> xxx.com application-group=%{GLOBAL}
>
> to force preloading. Remove the WSGIImportScript directive.
>
>     <Directory /srv/django/xxx/xxx/>
>         WSGIApplicationGroup xxx.com
>
>
> Since you only have the one application and are using daemon mode, you 
> should use:
>
>     WSGIApplicationGroup %{GLOBAL}
>
> But then you don't need this directive at all if you are forcing 
> pre-loading and have supplied application-group option to WSGIScriptAlias. 
> See above.
>
>         WSGIScriptReloading On
>
>
> This is the default, you don't need this directive.
>
>         Order allow,deny
>         Allow from all
>     </Directory>
>
>     ...
>
> </VirtualHost>
>
>
> Any help would be greatly appreciated and if anyone can point me in the 
> right direction as to how to debug this issue further I will gladly oblige 
> to the best of my ability!
>
>
> Make those changes and see how it goes.
>
> Because you have been force pre-loading, the WSGI application should be 
> getting loaded when daemon processes start, not on first request.
>
> Graham
>
>

-- 
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.

Reply via email to