4

I believe nginx is event based so with 1 single worker it can take multiple requests, say 100requests/second. These requests will then be pass on to uwsgi to be process and then once it's done it will push the result back to nginx and nginx will push the result to the user that do http request.

Assuming I am only using 1 worker(no thread) for my uwsgi, uwsgi will process this 100 request one by one right? So it will need to do 100 processes to complete the entire requests. Now what happen if I am planning to use long polling to get a quick update on my front end How does facebook, gmail send the real time notification?

I believe it will force the uwsgi to process a single request(which is the long polling process) and suspend all the other requests, hence causing the entire system to broke down.

Do I have any misconception of how uwsgi work, or is there any other solution to implement long polling?

Thank You

Community
  • 1
  • 1
Angky William
  • 171
  • 2
  • 6
  • 1
    This is an interesting question but it has a bad title. How about changing it to this, to attract the attention of people who can help: "Are uwsgi processes kept idle when using Comet?" And maybe also add "comet" to the tags. And note that this question is probably more appropriate for http://serverfault.com/. – Antonis Christofides Aug 20 '13 at 09:47

1 Answers1

1

Your analysis is right, long-polling is not well-suited for multiprocesses or multithreads modes (in term of costs). Each process/thread can manage a single request. Lucky enough uWSGI supports dozens of non-blocking/evented/microthreads-based technologies (like gevent, or lower-levels greenlets), if your app can be adapted to this patterns (and this is not a no-brain task, so do not hope monkey-patching will be enough) you will win.

In addition to this, if you like/tolerate callback-based programming and you do not need uWSGI specific features, i find Tornado a great solution for the problem.

roberto
  • 12,723
  • 44
  • 30
  • I see, do you suggest running tornado directly or running tornado behind a nginx? What I found so far is http://www.quora.com/Tornado-web-framework/If-Tornado-has-to-be-backed-up-by-Apache-or-nginx-why-does-it-have-a-web-server Do you agree with it? Thanks – Angky William Aug 21 '13 at 04:47
  • as a general rule never run the application server directly exposed to the public network. So yes, i agree with the post – roberto Aug 21 '13 at 14:48