CGI, FastCGI, whatever - what are they?

There are many ways to connect your application to web-server. Most common are CGI and FastCGI modes and running application as an HTTP server.

CGI mode

CGI which stands for Common Gateway Interface was the first way to launch external app from webserver and get something done. For each client request, a new application was spawned, did some calculations and any given response was forwared to client.

PROS:

CONS:

Dedicated FastCGI mode

FastCGI is a way to run an application continiously so that it would wait in infinite cycle and respond to requests, one after another. An example given is more relevant to languages like C++ and Perl, since NodeJS has (only some) parallelism emulation.

PROS:

CONS:

Apache2-launched FastCGI mode

FastCGI can be started by developer (or system or something) or can be dynamically spawned/killed by web-server, for example, apache. In this case, if we are already calculating PI number inside current request 3, we can still spawn a new process and start another calculation round on another process core.