The Common Gateway Interface (CGI) is a web server helper that delegates the generation of web content to executable files (applications). Such files are known as CGI scripts; programs or stand-alone applications, usually written in a scripting language.
The CGI protocol starts a separate process at the beginning of each HTTP request and terminates it after execution is complete. This "new process for each new application" model is very simple to implement.
CGI has the following advantages:
Independent of programming languages - CGI applications can be written in almost any language.
Isolated processes - Applications run in separate processes, which provides security and stability.
Open standard - CGI is implemented in every web server.
Architectural independence - CGI is not tied to server architecture.
CGI also has some drawbacks, the main one being productivity. This can be observed in frequently performed processes. Because a new process is created for each request and terminated after execution, the efficiency is lower than the FastCGI protocol.
FastCGI is a newer, faster and optimal way to run the web server with additional applications.
The benefits of FastCGI include:
High performance - FastCGI processes are reused to service multiple HTTP requests, not just one. This solves the CGI problem of creating new processes for each request and increases productivity accordingly.
Easy migration from CGI - Applications written for CGI can be relatively easily migrated to FastCGI.
Independent programming languages - Like CGI, FastCGI applications can be written in almost any programming language.
Architectural Independence - FastCGI is supported in all server products on the market.