The ISAPI model was originally developed to be a higher-performing alternative to the Common Gateway Interface (CGI). The ISAPI model provides a number of advantages over the CGI model, including low overhead, fast loading, and better scalability.
The chief difference between the CGI programming model and the ISAPI programming model is that, with CGI, the system creates a unique process for every request, whereas ISAPI extensions do not require a separate process. With CGI, every time an HTTP server receives a request it must initiate a new process. Because the operating system must maintain all these processes, CGI is very resource intensive. This inherent limitation in CGI has made it difficult to develop responsive applications on the Internet.
The following diagram illustrates differences between the CGI model and the ISAPI model.
In the ISAPI model, each request received by an HTTP server initiates the creation of a EXTENSION_CONTROL_BLOCK data structure. Creating and maintaining a data structure is much easier and faster than initiating a new process. In addition, because the EXTENSION_CONTROL_BLOCK and the extension are usually both running in the same process as IIS, the server can process requests faster and can accommodate a higher number of requests.
Finally, rather than using process isolation, the ISAPI model uses threads to isolate different items of processing work. Because IIS uses multiple threads to synchronize work, it makes more efficient use of system resources than is possible with the CGI model, or other models based on process isolation.
IIS version 4.0 and later supports process isolation for ISAPI DLLs and scripts. IIS uses custom high-speed methods to establish communication between the server process and the surrogate process housing the ISAPI DLLs, thus providing robustness with high performance.
When IIS receives a request for a particular extension, it loads the DLL into memory, where it services other requests. For example, the following HTTP request causes IIS to create an instance of MyISAPI.dll.
http://IIS/Applications/MyISAPI.dll?paramater1,parameter2
When IIS unloads the extension, it calls the extension's TerminateExtension function, if present. You are encouraged to use TerminateExtension to free any resources that the extension may have locked or allocated when it was initially loaded.
For more information about CGI, refer to http://hoohoo.ncsa.uiuc.edu/cgi/.