Limiting the maximum number of concurrent django / apache requests

I have a django site that demonstrates the use of the tool. One of my views accepts a file as input and performs quite heavy calculations through an external python script and returns some output to the user. The tool works fast enough to return the result in the same query. However, I would like to limit the number of concurrent requests to this URL / view so that the server does not overload.

Any tips on how I will do this? The page itself is very simple, and usage will be low.

+4
source share
2 answers

Assuming you are using mod_wsgi, you can segment your WSGI application through several process groups of the mod_wsgi daemon with specific URLs that you want to limit to delegated by your own mod_wsgi daemon process group, with fewer processes / threads.

WSGIDaemonProcess myapp processes=2 threads=10 WSGIDaemonProcess myapp-restricted threads=2 WSGIScriptAlias / /some/path/app.wsgi WSGIProcessGroup myapp <Location /some/specific/url> WSGIProcessGroup myapp-restricted </Location> 

Note that requests queued to access these two threads in a restricted process will still consume the workflow in the main child processes of the Apache server. So you want you to use working MPM (so not mod_php) and configure MPM with enough spare threads to handle these backup requests, as well as normal traffic.

+4
source

This is really a question about mod_wsgi, assuming you use this to serve your application from Apache (and if not, you really should be).

The creator of mod_wsgi, Graham Dumpleton, sometimes hangs around these parts, but, waiting for his appearance, you can look at the excellent documentation . It seems that this or that argument in the WSGIDaemonProcess directive may be what you are looking for.

+1
source

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


All Articles