Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How can I prevent Nginx from buffering the output of my uwsgi app? For my comet style application I'm using long polling and the requests are now buffered.

I tried to reduce the size of the buffers, but I'm not allowed to put uwsgi_buffer_size and uwsgi_buffers on 0. Also uwsgi_max_temp_file_size does not work (eventhough the manual suggests that).

How can I do this?

share|improve this question

4 Answers 4

up vote 9 down vote accepted

Until a few minutes ago this was not possible. nginx would always buffer all uwsgi and scgi responses, and no configuration would change that.

I have submitted a patch for nginx (and it was accepted) and from the next version on there are two methods to disable buffering for uwsgi requests:

  • put uwsgi_buffering off in the nginx config
  • send a X-Accel-Buffering 'no' header in the response

uwsgi never buffers the response, so no configuration is required on that end.

share|improve this answer

Why don't you use the uwsgi-embedded http-router/load-balancer directly ? It does no-buffering expecially for comet/websockets app. You can use nginx for static files mapping them to another domain.

share|improve this answer
    
In that case I could also http proxy the requests through nginx, as for proxying there are specific buffering flags. The thing I'm doubting is that uwsgi http server is able to give me a good performance and security. –  Peter Smit Aug 4 '11 at 8:55

Try with uwsgi_max_temp_file_size = 0

share|improve this answer
    
As I wrote in the question, this does not work. –  Peter Smit Aug 3 '11 at 3:03

Nginx "proxy" module has a directive for that, it's called proxy_buffering on|off, which does exactly what you want, it turns buffering off and proxies upstream output synchronously. But AFAIK neither FastCGI nor UWSGI modules have it.

BTW even when proxy_buffering is off, you may notice small delays because of OS TCP stack buffering.

share|improve this answer
    
Indeed, if I would use proxy_pass then this would be useful. But as I mentioned I use uwsgi so this does not work. –  Peter Smit Aug 4 '11 at 10:33
    
Ok, I'll tell you plainly: there is no solution. Is downvoting your motivation for people? Good luck. –  Alexander Azarov Aug 4 '11 at 14:08
1  
Please don't take the downvote personal. A downvote means "This answer is not useful". So I downvoted it as it was not useful to me, because it does not give an answer to my question. –  Peter Smit Aug 4 '11 at 16:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.