Product SiteDocumentation Site

2.2. Threaded servers

High numbers of connections can easily lead to memory shortage — forked children touching their virtual memory mean duplication of the backing pages. In the worst case, touching a single byte leads to copy-on-write of a whole page. A way to mitigate this challenge is to use threads instead of forked child processes.
An advantage of both, the forking and the threaded architecture is the fact that the program flow is linear. The blocking system calls read(2) and write(2) can be used as needed. This eases programming and software maintenance in the context of these architectures.