DB2 Connect and web applications


The web browser is rapidly becoming a standard interface for everything from online catalogs to intranet applications. For simple web applications, a web server alone might be sufficient. For high-volume applications that require database access and transaction processing, IBM® offers solutions that use DB2 Connect™ to manage very high numbers of simultaneous transactions over the web.

Advantages and limitations of traditional CGI programming

e-business applications on the World Wide Web typically use the Common Gateway Interface (CGI) to enable users to query back-end databases. Many companies also use web applications internally, and these usually have a database in the background as well.

Users fill out forms on a web page, and these forms are submitted via CGI to applications or scripts on the web server. The script will in turn use a provided database API to submit SQL queries to a host database. The same script can then build a web (HTML) page with results of the query and send it back to be displayed by the user's web browser. An example is an online catalog where the user can query the availability and current price of particular goods or services.

CGI applications can be simple to design and easy to maintain. Since the CGI standard is both operating system- and language-independent, it is available on nearly all computing platforms. CGI programs can be written in C++, or in a scripting language such as Perl or PHP.

While CGI might seem like an ideal solution for web-based applications, it has significant shortcomings. The programming environment for CGI is not as sophisticated as other APIs. In addition, scalability can become an issue with large-scale e-commerce operations. Every time a CGI application is invoked, a new process is created on the web server. Each process must make its own connection to the database and submit its own query. In high-volume transactional environments, this limitation can create significant performance issues.

You can use DB2 Connect with a web server to create robust, high-volume e-commerce applications. DB2 Connect provides several solutions that improve web-based application performance. Stored procedures allow DB2 Connect users to reduce the number of queries being sent to the database.

Connection pooling reduces the frequency of connections and disconnections to and from a database.

Using PHP as a Web Server module or plug-in

Although PHP can be used for CGI programming, it is commonly used as a web server module or plug-in. In a multi-process web server such as Apache, the IBM DB2® driver for PHP can be used to mitigate the scalability issue. In a multi-process web server, a pool of processes are reused to service web server requests. To remove the need of building a database connection for every web request, a persistent connection can be created. In this environment, a persistent connection can exist beyond the scope of a single PHP script. The connection will be reused if an identical connection is needed by a subsequent web request.

Parent topic: DB2 Connect scenarios