How to prevent django mod_wsgi application from restarting again?

My mod_wsgi django app seems to keep loading for the first few requests the client makes. It kills my work

After enough requests, it seems to calm down, and the application no longer looks like a reboot. Any thoughts on why this is happening and how I can prevent it?

(I have the following in httpd.conf: MaxRequestsPerChild 0 , so this is not the case)

+4
source share
1 answer

This is probably due to the fact that you are using the mod_wsgi and Apache native mode on UNIX systems, perhaps even with MPM Apache prefork, which makes things worse. In short, in this configuration, Apache is a multiprocessor web server. Combine this with the fact that, by default, for a lazy load application on first request, you will see a delay in the initial request against each child process of the Apache server when the application loads.

Even for the Django framework, this should not be excessive and will question what your particular application does at startup to cause a long delay or a big load spike.

To understand the problems, make sure you read:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

Then change the usage of the mod_wsgi daemon mode as described on the mod_wsgi wiki pages. In particular, start with:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

If you really need to start more than one daemon process, and not just hope what load your application will load, and the load time is still a concern, then you can configure mod_wsgi using WSGIImportScript and other ways to preload your application WSGI during the start of the process before any requests appear. However, for Django, make sure you use the WSGI script file described in:

http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html

not the one described in the Django documentation, as it lazily loads, and you can still see problems, as well as behavioral differences between WSGI hosting mechanisms and the embedded development server.

+4
source

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


All Articles