About CGI

Limitations . . Home

Common Gateway Interface (CGI) is a protocol for forking processes on a Web server that read from standard in and write to standard out.

A Web browser forks a CGI application and passes it parameters through standard in. The CGI application doesn't have to connect to a database. It simply generates an HTML page which is returned to the browser via standard out. After the page is returned, the CGI program exits. The CGI program itself can be written in a variety of programming languages. Perl is a popular language for CGI applications.

Simple Web database connectivity solutions use CGI as a vehicle to attach to the database and process a transaction. It is fairly easy to extend the CGI architecture to the database by having your program attach to the database, use stdin parameters to build and process a transaction, and then format the results in HTML.

This technique provides a simple mechanism for basic database connectivity. However, there are some issues that this architecture does not address. Some applications require a more sophisticated interface to the database. INFORMIX-Universal Web Connect provides additional power to overcome these limitations.

Limitations of CGI-Based Database Interfaces

The CGI architecture does not address the needs of all applications.

Maintaining State

Since the CGI application is forked by the Web browser with each request, it must re-establish a database connection each time. Applications that then require a persistent database connection have to use complicated techniques to address this issue.

For example, if you wanted to write an application that takes query criteria from the user and allows the user to view the resulting records using the "Next" and "Previous" functionality, it would be somewhat difficult to do. This is because there is no way to open a cursor and maintain it. You would have to develop some sort of token passing algorithm to figure out who the user was, what query they were running and where they were in the result list. It is not impossible, but can be very difficult.

As your applications grow in complexity and require the ability to process complex transactions, it may very well become inpossible to use this basic CGI architecture.

Performance Considerations

A multi-user application that performs multiple database connections can involve substantial overhead. For a limited number of users, this may not be an issue. However, as you scale to large numbers of concurrent users, performance becomes a major issue.

Additionally, in the CGI architecture, applications also incur the overhead of constantly re-opening cursors that can't be maintained since the database connection is not persistent. This can result in more communication between the application and the database than normal.


Top of Page . . Home