Django file upload took forever with Phusion Passenger

544 views Asked by At

I have a Django app deployed using Passenger (I did not choose mod_wsgi because mod_passenger is already there and being used). When I uploaded an MP3 file (900 kB), Google Chrome displays upload % which reached 100% pretty fast but then it took forever for the resulting page. The database (containing the file's metadata) does not show anything uploaded.

The Django logic should be OK because everything works in the development machine (built-in Python server)

My config: Django 1.8, Apache 2.4, Ubuntu 14.04

1

There are 1 answers

6
Hongli On BEST ANSWER

Passenger author here. Try setting passenger_log_level to a higher value, which may give you insights on why this is happening.

I don't know which Passenger version you are using, but in version 5, the Passenger request processing cycle looks like this:

  1. Apache receives the request. Once headers are complete, it forwards the request to the Passenger server process while at the same time streaming the request body to the Passenger server process.
  2. The Passenger server process buffers the entire request, including body. This buffering takes place in a temp file that is immediately unlinked.
  3. Once buffering is complete, the Passenger server process forwards the request (including the body) to the Django app. Passenger then waits for the app to generate a response.
  4. The Passenger server process streams the response from the Django app to Apache. No blocking buffering takes place here.
  5. Apache streams the response from the Passenger server process to the client. No buffering takes place here.

With a sufficiently high log level, you can see how much time each step took so that you can pinpoint the culprit.

Note that the request processing cycle is different in earlier versions of Passenger. My advice applies only to version 5.