I am new to Java and to web development in general so I am reading this tutorial where it says that one advantage of the servlet pattern over CGI is:
better performance: because it creates a thread for each request not process.
However, I really do not get why it should be so. Based on this answer, at least for Linux, the general consensus seems to be that threads are not necessarily faster than processes and it might be actually advantageous to use processes instead of threads.
In the tutorial it is written that CGI works as follows:
For each request, it starts a process and Web server is limited to start processes.
When taking into account the startup cost of a process, this could make sense. However, I am not sure why it would be necessary to start a new process for each request, instead of having a pool of running CGI shells serving the queued requests.