2

Nginx uses epoll to communicate clients and it's very efficient, but how Nginx communicate with upstreams, I google and get a answer from quora http://www.quora.com/How-can-nginx-handle-concurrent-requests-with-a-single-worker-process, but the answer doesn't answer the question, I check the source code of Nginx,it has a implementation of thread pool ,the file: http://trac.nginx.org/nginx/browser/nginx/src/core/ngx_thread_pool.c I don't good at C, so I don't know how nignx use the thread pool.

but if nignx work process use single thread to deal with all requests, when nignx wait for data from upsteam, it should block the thread, so the thread can't service other requests, but in fact, Nginx does a good job with upstreams, how does it be implemented?

windrain
  • 75
  • 2
  • 9
  • See my answer here: http://stackoverflow.com/a/19324665/362536 I mention Nginx near the middle of it. – Brad Mar 21 '15 at 17:03
  • 1
    @Brad thanks for your answer, your answer is very lovely, but I think you just answer how epoll event running -- async, but every request that nginx has accepted must be send to upstream to get data, such as fastcgi server, if the server is php, php may be communicate with database, after some time, php return data to fastcgi, fastcgi return to nginx ,nignx use epoll event write data to client, during the time, I think if nginx is a single thread, it may be blocked and wait for some time. – windrain Mar 21 '15 at 17:13

0 Answers0