Difference analysis:
(Recommended learning: nginx tutorial)
cgi
web server will According to the content of the request, a new process will be forked to run the external C program (or perl script...). This process will return the processed data to the web server. Finally, the web server will send the content to the user. The process just forked will also Then exit.
If the user requests to change the dynamic script next time, the web server will fork a new process again, and the process will continue again and again.
fastcgi
When the web server receives a request, it will not re-fork a process (because this process is started when the web server starts and will not exit). The web server directly Pass the content to this process (inter-process communication, but fastcgi uses another method, tcp communication). This process processes the request after receiving it, returns the result to the web server, and finally waits for the next request to arrive. Instead of quitting.
To sum up, the difference lies in whether to repeatedly fork the process and process the request.
The above is the detailed content of What is the difference between fastcgi and cgi. For more information, please follow other related articles on the PHP Chinese website!