Difference between Multi and Single Thread

2

In terms of processes, what is the difference between multi-threaded and single-threaded pro? How will both forms work with a request?

    
asked by anonymous 16.07.2015 / 20:15

1 answer

2

It has more architectures in addition to single-thread (ST) and multi-thread (MT). Basically the ST can only handle one request at a time, so the processing of each can not be time-consuming, nor can it block (for example, waiting for the database). MT, assuming you create one thread per request, can handle multiple requests in parallel, even if they delay or block.

An ST server can be effective as long as it never blocks. Node.js is asynchronous so as not to block. Any lengthy processing should be delegated to another process, which can also be done on the Node with subprocess.

Another way to approach the problem: Apache prefork creates a pool of subprocesses, and delegates the requests to each subprocess as they arrive. This ensures parallelism and avoids the complexities of MT programming. This can be implemented also on the Node but Apache delivers it from the factory, which makes the PHP developer's life easier for example, since he does not have to worry about blocking.

    
13.08.2015 / 05:33