开发者

How does nginx handle long running requests like file downloads?

开发者 https://www.devze.com 2023-03-22 23:38 出处:网络
From my limited understanding of nginx I know that nginx seperates itself from Apache by using a single thread that handles all requests instead of Apache which throws threads at the problem. In theor

From my limited understanding of nginx I know that nginx seperates itself from Apache by using a single thread that handles all requests instead of Apache which throws threads at the problem. In theory with a bunch of small requests its faster. But what about long running requests.

Lets say a user is downloading a large file or there's some long running PHP script that's slow because of something its depending on (disk IO, database) is slow. With Apache everything has its own开发者_JAVA技巧 thread so while PHP is waiting for a response from the database another request can come in and be simultaneously processed. With nginx however, wouldn't something like that lock the thread and therefor the whole server? I know that you can have multiple nginx processes but creating more processes for just file downloads just seems like trying to recreate Apache.

I know I'm missing something here as nginx handles situations like this, but what? How does nginx do this with its threading model?

And before you say it, this isn't a duplicate of this question as it only talks about incoming connections


Worker processes in nginx can handle multiple incoming and outgoing requests simultaneously. The answer to the question you linked (3436808) is also applicable to this question.

0

精彩评论

暂无评论...
验证码 换一张
取 消