Sunday, February 04, 2007

Advantages and Disadvantages of CGI

CGI is a standard protocol for interfacing external application software with a Web server [1]. It has been widely used for implementing dynamic generated pages on the Web.
There are advantages and disadvantages to CGI programs. One advantage of CGI programs is that they are language independent [2]. CGI programs can be written in any language that allows one to write normal programs since they are executed in the same way as the normal programs. Another advantage of CGI is that it's a very simple interface [3]. It's not necessary to have any special library to create a CGI program, or write programs using a particular API. Instead, CGI programs rely on the standard concepts of standard input, standard output, and environment variables to communicate with the Web server.
There are also disadvantages to CGI programs. One disadvantage is that CGI programs are slow since they need to fork a new process for every HTTP request and the database connection must be reopened for the next instance of the program, which is quite costly [4]. One solution is to use FastCGI instead of CGI. FastCGI implements a technique using which forking one process for every request is not necessary, therefore can improve the performance.

[1] http://en.wikipedia.org/wiki/Common_Gateway_Interface
[2] http://www.scit.wlv.ac.uk/~jphb/sst/basics/cgiintro.html
[3] http://proquest.safaribooksonline.com/0672324040/ch01lev1sec5
[4] http://proquest.safaribooksonline.com/1565923790/ch15-27259

No comments: