Is mod_wsgi overly slow at startup?

I am developing a django site that uses mod_wsgi for production - there are hardly any visitors, so anytime I visit it it seems that the wsgi mod starts and opens python processes - it takes about 1-2 whole minutes to fully load.

Is there anything I could do to keep it from slowing down on initial startup? Is this a common problem or could it be a problem for my configuration?

+4
source share
2 answers

This should not last so long, even if you used the suboptimal configuration using the built-in mode and Apache prefork MPM. Although, you could do something worse if you have MaxRequestsPerChild set to 1 for Apache processes.

The following recommendations are suggested: make sure that you use the mod_wsgi daemon mode and start using a single multi-threaded process (the default settings for WSGIDaemonProcess). This will ensure at least that there is only one instance of Django and not potentially one per Apache server process.

As a confirmation of what you are doing, edit your question and post a snippet of the current Apache configuration that shows how to configure the mod_wsgi bits. Also include whether you are using the Apache pre-program or the working MPM that is detected when 'httpd -V' is run and which platform you are using.

By the way, have you tried the simple WSGI world greeting program to test your installation? See ' http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide '. And have you tried with an empty Django site, not your real one, to find out if your changes are?

+6
source

Just some more light on this. You do not want to use the prefork MPM period, this will call the 1x mod_wsgi process for each of the pre-processed processes.

The best way to overcome this is to start the WSGI process in Daemon mode using the working MPM.

https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode

Edit:

Also note that you MUST specify a group, otherwise each HTTPD process would seem to create its own mod_wsgi process after all connections have been closed.

WSGIScriptAlias ​​//usr/local/apache2/htdocs/ABC.com/build/wsgi.py WSGIPassAuthorization On WSGILazyInitialization Off WSGIDaemonProcess ABC.com user = apache group = apache display- name =% {GROUP} processes = 1 threads = 256 WSGIProcessGroup ABC.com

0
source

Source: https://habr.com/ru/post/1302940/


All Articles