1

I have setup a Linux server with Apache and mod_wsgi. From my Apache configuration:

WSGIDaemonProcess myapp processes=1 threads=10

Here myapp is a Django webapp. When myapp receives a large http POST request from Apache in a Django HttpRequest object, accessing the posted data the fist time takes several seconds of wallclock time. I assume this is because myapp is invoked before the full body of the POST is read from the network and that accessing the posted data in the HttpRequest object blocks until the posted data is read.

Is there a way to not have myapp invoked until Apache has read all the posted data?

I ask because I want to tune the number of threads (in this case 10) to what is most optimal for concurrent processing in myapp. Therefore, I do not want to spend time in these requests on just waiting on receiving posted data from the network.

I am aware that I could potentially increase the number of threads to more than 10 and implement another mechanism to ensure that at most 10 threads are processing concurrently.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
user1772004
  • 165
  • 1
  • 6

1 Answers1

0

How large is large?

If it is very large, then you risk blowing out memory usage if something were to pre read it all into memory before even handing it off to the web application. Anyway, there is no means in Apache/mod_wsgi to do such a pre read.

Using nginx as a proxy in front of Apache/mod_wsgi can help to isolate Apache from slow HTTP clients, but nginx only pre reads before proxying for request content sizes up to 1MB. Allow pre reading and buffering on large request content sizes and then you have to worry about memory usage as mentioned.

What you should perhaps do is offload those specific URLs to nginx to handle with an upload manager. For example:

Graham Dumpleton
  • 57,726
  • 6
  • 119
  • 134