Workflows in asynchronous servers


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
16 views
Hello.

I can not fully deal with this topic as worker processes (workers) to asynchronous servers. Why they are needed and whether they make sense?
For example, in nginx worker processes are normal: nginx.org/ru/docs/ngx_core_module.html#worker_processes
In lighttpd they are not advised to use: redmine.lighttpd.net/projects/1/wiki/Docs_MultiPro...

1. Whether they are necessary actually?
2. And a question to those who are engaged in the development of asynchronous servers markerami or dealt with them: how all this is implemented at a low level? Connection accepted (accept) from the main process and then as it passed one of the child workarou or all of worker simultaneously listening to a socket?
by | 16 views

3 Answers

0 like 0 dislike
if at a low level it's simple. The main process listens to a socket and does accept. Then there are 2 options: to multiplex requests (from an array to select sockets ready to read using select/epoll and do a recv or accept depending on what the socket is ready to provide the data) or you can push the handling socket to a private thread/process. The process is safer because if it falls then the server this doesn't matter.

And then have to go optimize. The same nginx uses multiplexing within processes-workarou. Multiplexing allows more rationally to use resources within a single process, but several processes allow you to process more requests in parallel. At the same time, the processing of these queries does not affect the main process listens to the socket for new connections.

About the very workarou. As a fork of a new process, yet the operation is not that cheap, is such a practice as prefork. That is in memory already spinning a certain number of ready processes and the appearance of processing requests they just transferred there. Increasing the number of queries increases the number of workarou that minimizes the loss from blocking processes...

generally googling about the problem 10k, you can Google a bunch of algorithms for processing queries.

As for the lighttpd documentation describes cases when you need to use multiprocessing, and the possible problems with the modules. It tips "no use" there is not present.
by
0 like 0 dislike
The meaning is, because, by default, an asynchronous application is running in a single thread, i.e. it can load more than one processor core.
If one core is small and / or there is a risk that the stream will occur for a long operation - increase the number of workerb.
In Lighty multithreading tweaked so carefully, so be warned.
In Nginx e no problems, put "auto".
by
0 like 0 dislike
The main point is that processing is based on event-driven model. This uses epoll/kqueue and such decisions depending on the OS. Following is not one place, in this case without the use of threads would use only one core, which is wrong (that is why well drained libuv library (developed for node.js), libevent and such). In order to fully utilize all CPU cores and runs one process per core. The idea would be to use multithreading, but in this case, you need sync, and it in turn will have a negative impact on performance.
by

Related questions

0 like 0 dislike
3 answers
asked Apr 5, 2019 by Runcorn
0 like 0 dislike
3 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
asked Mar 24, 2019 by Igozzzz
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
35,393 users