Welcome! Log In Create A New Profile

Advanced

thread_pool in Windows

Posted by Sergey Sandler 
Sergey Sandler
thread_pool in Windows
March 04, 2018 04:30AM
Hi,

I am running Nginx as a proxy for a single-threaded server (Shiny R) in
Windows;both the proxy and the server are located on the same machine. There
are delays due to timeout errors:
"upstream timed out: A connection attempt failed because the connected
party did not properly respond after a period of time, request: "GET
/shared/jquery.min.js HTTP/1.1""
(and similar for other js and css files).

This can probably be solved with 'location alias'. But this is tedious,
since the required files are spread out in R/Lib subdirectories.

The proper fix seems to be by restricting thread_pool with
thread_pool io_pool threads=1;
and a corresponding directive under 'location'
aio threads=io_pool;
However, Nginx reports: unknown directive "thread_pool".

Is there a way to have 'thread_pool' supported in Windows?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278909,278909#msg-278909

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: thread_pool in Windows
March 04, 2018 04:50PM
Hello!

On Sat, Mar 03, 2018 at 10:27:21PM -0500, Sergey Sandler wrote:

> I am running Nginx as a proxy for a single-threaded server (Shiny R) in
> Windows;both the proxy and the server are located on the same machine. There
> are delays due to timeout errors:
> "upstream timed out: A connection attempt failed because the connected
> party did not properly respond after a period of time, request: "GET
> /shared/jquery.min.js HTTP/1.1""
> (and similar for other js and css files).
>
> This can probably be solved with 'location alias'. But this is tedious,
> since the required files are spread out in R/Lib subdirectories.
>
> The proper fix seems to be by restricting thread_pool with
> thread_pool io_pool threads=1;
> and a corresponding directive under 'location'
> aio threads=io_pool;
> However, Nginx reports: unknown directive "thread_pool".

The error message indicate that your upstream server can't cope
with load. Using thread pools in nginx won't help you with this,
you need to either tune your upstream server to handle more load,
or move some load away from it, e.g., by serving static files
directly by nginx.

> Is there a way to have 'thread_pool' supported in Windows?

Thread pools support for Windows is not implemented. If you need
them supported, you have to code relevant code bits first. But,
as explained above, this won't help with your particular problem.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sergey Sandler
Re: thread_pool in Windows
March 06, 2018 01:50AM
Hi Maxim,

Thank you for prompt reply.

I suspect there would be no delays/timeouts if there was a single thread in
nginx that communicates with the upstream server.
There is no simple way to restrict nginx threads number to one in Windows?

Serving static files directly by nginx will likely solve the issue; it is
not straightforward extracting static files (css, js) since in the Shiny R
context they are spread in R libraries subfolders.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278909,278934#msg-278934

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Valentin V. Bartenev
Re: thread_pool in Windows
March 06, 2018 02:00PM
On Monday 05 March 2018 19:46:42 Sergey Sandler wrote:
> Hi Maxim,
>
> Thank you for prompt reply.
>
> I suspect there would be no delays/timeouts if there was a single thread in
> nginx that communicates with the upstream server.
> There is no simple way to restrict nginx threads number to one in Windows?
>
[..]

nginx currently cannot use more than one thread in Windows for all operations.

Support for thread pool means adding support for more threads. Moreover, thread
pools in nginx are used only for reading and writing files. They are never used
for connections.

wbr, Valentin V. Bartenev

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sergey Sandler
Re: thread_pool in Windows
March 07, 2018 04:40AM
Thank you, Valentin.

There is something I am missing. Please see the start of the error.log
below,

2018/03/04 14:05:50 [notice] 5144#9212: using the "select" event method
2018/03/04 14:05:50 [notice] 5144#9212: using the "select" event method
2018/03/04 14:05:50 [notice] 5144#9212: nginx/1.12.2
2018/03/04 14:05:50 [notice] 5144#9212: nginx/1.12.2
2018/03/04 14:05:50 [info] 5144#9212: OS: 260200 build:9200, "", suite:300,
type:1
2018/03/04 14:05:50 [notice] 5144#9212: start worker processes
2018/03/04 14:05:50 [notice] 5144#9212: start worker processes
2018/03/04 14:05:50 [notice] 5144#9212: start worker process 13648
2018/03/04 14:05:50 [notice] 5144#9212: start worker process 13648
2018/03/04 14:05:51 [notice] 13648#4924: nginx/1.12.2
2018/03/04 14:05:51 [notice] 13648#4924: nginx/1.12.2
2018/03/04 14:05:51 [info] 13648#4924: OS: 260200 build:9200, "", suite:300,
type:1
2018/03/04 14:05:51 [notice] 13648#4924: create thread 17496
2018/03/04 14:05:51 [notice] 13648#4924: create thread 17496
2018/03/04 14:05:51 [notice] 13648#4924: create thread 16328
2018/03/04 14:05:51 [notice] 13648#4924: create thread 16328
2018/03/04 14:05:51 [notice] 13648#4924: create thread 13940
2018/03/04 14:05:51 [notice] 13648#4924: create thread 13940

There is a single process (worker_processes 1 in the nginx.conf), with
seemingly three threads (not sure why the lines in the log file are
duplicated). Is the purpose of the additional threads to read static files
(from the server)?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278909,278946#msg-278946

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Ruslan Ermilov
Re: thread_pool in Windows
March 07, 2018 09:30AM
On Tue, Mar 06, 2018 at 10:38:21PM -0500, Sergey Sandler wrote:
> Thank you, Valentin.
>
> There is something I am missing. Please see the start of the error.log
> below,
>
> 2018/03/04 14:05:50 [notice] 5144#9212: using the "select" event method
> 2018/03/04 14:05:50 [notice] 5144#9212: using the "select" event method
> 2018/03/04 14:05:50 [notice] 5144#9212: nginx/1.12.2
> 2018/03/04 14:05:50 [notice] 5144#9212: nginx/1.12.2
> 2018/03/04 14:05:50 [info] 5144#9212: OS: 260200 build:9200, "", suite:300,
> type:1
> 2018/03/04 14:05:50 [notice] 5144#9212: start worker processes
> 2018/03/04 14:05:50 [notice] 5144#9212: start worker processes
> 2018/03/04 14:05:50 [notice] 5144#9212: start worker process 13648
> 2018/03/04 14:05:50 [notice] 5144#9212: start worker process 13648
> 2018/03/04 14:05:51 [notice] 13648#4924: nginx/1.12.2
> 2018/03/04 14:05:51 [notice] 13648#4924: nginx/1.12.2
> 2018/03/04 14:05:51 [info] 13648#4924: OS: 260200 build:9200, "", suite:300,
> type:1
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 17496
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 17496
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 16328
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 16328
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 13940
> 2018/03/04 14:05:51 [notice] 13648#4924: create thread 13940
>
> There is a single process (worker_processes 1 in the nginx.conf), with
> seemingly three threads (not sure why the lines in the log file are
> duplicated). Is the purpose of the additional threads to read static files
> (from the server)?

nginx for Windows only uses one worker process, and inside it only
one worker thread is created. You see three threads because it also
creates two other threads for cache_manager and cache_loader (these
are implemented as separate processes on UNIX):

if (ngx_create_thread(&wtid, ngx_worker_thread, NULL, log) != 0) {
goto failed;
}

if (ngx_create_thread(&cmtid, ngx_cache_manager_thread, NULL, log) != 0) {
goto failed;
}

if (ngx_create_thread(&cltid, ngx_cache_loader_thread, NULL, log) != 0) {
goto failed;
}


See also:

http://nginx.org/en/docs/windows.html#known_issues (item #1)
http://nginx.org/en/docs/windows.html#possible_future_enhancements (item #3)
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login