[cs631apue] fork or create thread
sshah83
sshah83 at stevens.edu
Sun Nov 2 23:03:51 EST 2014
Both approaches have its own pros and cons
Multi-threaded server can do caching because of shared memory and a
response can be cached and all the clients with same request get same
cached copy. Also forking a new process with each request can add a bit
of overhead because of creating COW copy than multi-threaded server
which is often faster and takes less memory.
On the other hand, in multi-threaded server, if a thread runs into a
problem while handling a request and crashes, it is probably going to
crash all other threads (handling all other requests at that time) and
may also crash the server. Where as multi-process server will provide a
complete isolation between each process/request and a problem in one
request will only cause to crash that process.
I think it is complex to write modules fully thread safe in
multi-threaded server.
-Sonal
On 11/02/2014 12:19 AM, zding4 wrote:
> Hi everyone,
>
> For our server and hw3, when server accept(2) a connection.
> We can fork a new process to handle this connection,
> I think we can also create a new thread(pthread) to do the same job,
> which one do you prefer?
>
> Sincerely,
> Zhizhuo
> _______________________________________________
> cs631apue mailing list
> cs631apue at lists.stevens.edu
> https://lists.stevens.edu/mailman/listinfo/cs631apue
More information about the cs631apue
mailing list