If you want to improve the performance of your Web site, your first impulse might be to buy more hardware. After all, you can add inexpensive hardware components to increase the amount of memory, disk speed, and processing power on your machine. But you can optimize the performance of Internet Information Server (IIS) without adding hardware. You can fine-tune your Web content to put less stress on your system. (For information about tuning IIS, see Ken Spencer, "Optimizing IIS for Peak Performance," May 1998.)

Your Web site's content can be static or dynamic. Static Web content places few demands on the Web server because such content consists of standard HTML code that requires no server-side or client-side programming or scripting. When a browser requests a static Web page, the Web server simply passes the page's content to the browser. In contrast, dynamic Web content can heavily tax a server because it might require substantial server-side programming or scripting. When a client's browser requests a Web page that includes dynamic content, the information the Web server delivers to the browser depends on the state of certain data on the Web server or the client.

For example, for a catalog, you can create a dynamic Web page that reads product information from a database and dynamically constructs HTML pages that contain the product information each customer requests. This configuration lets you build an online catalog that contains hundreds of products but uses much less code than a similar static HTML catalog. You create dynamic Web pages to run on an IIS server using three techniques: Common Gateway Interface (CGI), Internet Server API (ISAPI), and Active Server Pages (ASP).

CGI
CGI was the first solution for creating dynamic content on the Web. CGI lets you create an executable program or script that runs on your Web server and receives input from a user's browser through environment variables that the server sets for the browser, or through standard input that the server redirects to a communications pipe the server creates. The CGI program uses the input to perform functions such as querying a database. Then the CGI program writes the resulting dynamic HTML stream to standard output. The Web server redirects this output to a communications pipe it creates, then transfers the HTML output to the user's browser. Every time a user requests a CGI program, the Web server loads the program into memory and launches the program in a new process. CGI programs require a separate instance and process space for each browser request, so they consume large amounts of RAM.

You can develop CGI programs using C, C++, Perl, or other scripting languages. CGI development tools must be able to read environment variables and standard input and write to standard output. Listing 1 is a simple CGI program I developed in C. When a browser requests Listing 1's URL, the program writes an HTML response to the browser. For more information about CGI, check out http://hoohoo.ncsa.uiuc.edu/cgi.

ISAPI
Microsoft introduced ISAPI, which lets you create dynamic content using DLLs rather than executables, in IIS 1.0. After IIS loads an ISAPI DLL into the IIS process space, this one copy of the code services all browser requests for the ISAPI extension.

You implement ISAPI DLLs as extensions or filters. Like CGI, ISAPI extensions receive input from the user's browser, process that input, and send responses to the browser. Unlike CGI, ISAPI extensions perform these functions within the IIS process. To access data that the browser supplies and send responses to the browser, ISAPI extensions access the Extension Control Block, a memory structure IIS provides for communication between IIS and ISAPI extensions. This simple in-memory operation improves performance over CGI's piping of input and output between processes.

ISAPI filters implement event-driven preprocessing and postprocessing of browser requests. ISAPI filters are DLLs that exist in the IIS process space and receive specific tasks from IIS. When IIS starts, ISAPI filters register which part of server request processing they need to participate in. IIS invokes ISAPI filters when registered events occur. For example, an ISAPI filter might participate in performing authentication requests, preprocessing a header, or sending a response to the browser.

Listing 2 is an ISAPI extension that I wrote in C++. This ISAPI extension writes a message to the Extension Control Block, and IIS returns the message to the browser. For more information about ISAPI, see the IIS software de- velopment kit (SDK) at http://www .microsoft.com/msdn/library. You must be a member of the Microsoft Developer Network to access this site.

ASP
ASP premiered with IIS 3.0. ASP lets you embed server-side scripting within Web pages and interweave scripting and straight HTML without using sophisticated programs. The ASP engine runs as an ISAPI extension that processes requests for files with .asp extensions and connects the files' scripts to an ActiveX scripting engine for interpretation. After the scripting engine executes a script, IIS returns the resulting HTML page to the browser.

IIS comes with Visual Basic Script (VBScript) and JScript (Microsoft's implementation of JavaScript), and you can install other scripting engines, including Perl. Using ASP's built-in Server object, you can write script that instantiates other Active Server components, such as ActiveX Data Objects (ADOs), which provide objects for database access.

   Prev. page   [1] 2     next page



You must log on before posting a comment.

If you don't have a username & password, please register now.