asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Running ISAPI applications Within IIS 4.0
By Wayne Berry
Rating: 3.8 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Running ISAPI applications Within IIS 4.0

    The next version of the Internet Information Server, version 4.0, is a major change from version 3.0. One of the biggest improvements is the ability to run ISAPI applications in another process space. Version 3.0 of IIS and the previous versions required that all ISAPI applications run within the process space of the server. An ISAPI application is an extension to the server that allows programmers to write dynamic web pages. Both Active Server pages and the Internet Database Connector are ISAPI applications. The three main improvements in application management are:

    • The ability to run ISAPI applications outside of the process space of IIS.
    • The ability to load and unload ISAPI applications without effecting the rest of IIS.
    • The ability for IIS to start a new instant of an ISAPI application, after it's failure.

    ISAPI Performance

    One of the biggest advantages of an ISAPI application in IIS 3.0 is that it is fast. It is fast because once the server loads the ISAPI application into memory it is not released, making other calls quick because the operating system need not load the DLL again. Comparably, CGI executables are instantiated every time that they are called. The loading and running of the executable slows the response time of the page.

    ISAPI State

    Another advantage of loading ISAPI applications in IIS 3.0 into memory and not releasing them is that you can maintain state across multiple calls. By having global variables, protected with critical sections, you can save information about the application that spans several requests. This is usefully when you implement ODBC connection caching for additional speed. In comparison, CGI executables do not have a way of maintaining state across multiple requests.

    ISAPI Stability

    One thing that CGI executables do have in their favor is that they are more stable then ISAPI applications. In fact, they are not more stable, but they give the appearance of being more stable. This is true because of one single fact, if your CGI executable has a general protection fault, or crashes for some other reason, only one user is effected. This is because the general protection only effects the process that it is running in. General protection faults in ISAPI applications effect the process they are running in also, except they are running in the application process that the web server is running. ISAPI applications that crash usually crash the server also. The difference here is that ISAPI application crashes effect all the users that are currently on web site and usually all the users that follow the crash, while CGI executable crashes only effect that user.

    ISAPI Programmability

    Because ISAPI applications must be crash proof in IIS 3.0 there are few people qualified to write ISAPI applications. It takes are very good disciplined programmer to write crash-proof applications that handle all the error checking without effecting the other threads that are also running within the application. Besides the responsibility of writing rock hard applications, developers also have to deal with a wide range of varying input, since the user scenario of the Internet is very broad. Developers that came from writing Windows executables, where they could pass the error messages onto the user, are suddenly faced with a scenario where they must handle the error messages themselves within the code. Another thing that new ISAPI programmers face is the lack of leniency of memory leaks. Windows programmers in the past have been able to disregard small memory leaks in lieu of bigger bugs. However ISAPI applications, because they never unload, begin to consume large amounts of memory from even the smallest memory leaks. These things in combination have made ISAPI programming tough.

    IIS 4.0 Flexibility

    IIS 4.0 gives you more flexibility to manipulate ISAPI applications. You can choose to have the ISAPI applications execute within the server process, or in a separate process. You can also have the ISAPI applications remain loaded or unload after every request.

    IIS 4.0 Application Namespace

    IIS 4.0 allows you to run your ISAPI applications in a separate process space. The advantage here is that if the ISAPI application crashes, then neither IIS nor other applications are halted. In IIS 4.0 you cannot isolate the ISAPI individually, instead all ISAPI applications are isolated within the namespace of an IIS application. In order to run all ISAPI applications in a separate namespace you must create an application namespace. Here is how:

    1. Open up the Internet Server Manager within MMC.
    2. Click on the directory that you want to begin your application namespace at.
    3. While your directotry is selected, right click and choose Properties from the drop down menu.
    4. Depending on the type of directory, click on either the Home Directory, Virtual Directory, or the Directory tab.
    5. From within the Application Setting click on Create. This will create an application namespace that incorporates all the subdirectories physically under that application.
    6. Click on OK to exit.

    Figure 01 : Create Application Namespace

    IIS 4.0 Application Isolation

    Once you have an application namespace created, you can separate all the ISAPI applications and have them run from within a separate application. Here is how:

    1. Open up the Internet Server Manager within MMC.
    2. Click on the directory that you want to begin your application namespace at.
    3. While your directotry is selected, right click and choose Properties from the drop down menu.
    4. Depending on the type of directory click on either the Home Directory, Virtual Directory, or the Directory tab.
    5. From within the Application Setting check the box that says Run in separate memory space.
    6. Click on OK to exit.

    IIS 4.0 Isolation Scope

    By isolating all ISAPI applications to an application namespace, you not only isolate your ISAPI application but all Active Server pages and Internet Database Connector calls as well. For instance, lets say that you have an ISAPI application called myisapi.dll. The normal way that you call that application is by typing this into your browser:

    http://www.myserver.com/scripts/myisapi.dll?Name=Value
    
    Since myisapi.dll might crash the server, you play it on the safe side and isolate the DLL by creating a separate memory space for the myisapi.dll to run in. This application namespace includes /scripts and all of scripts subdirectories. However, also within scripts is some Active Server Pages. To request these, you can type this URL in the address space of your browser:
    http://www.myserver.com/scripts/mypage.asp
    
    Since you have isolated all applications running under the scripts virtual root, the request to the Active Server page will also run in a separate process from the server. This is because the .asp extension is mapped to the ISAPI application asp.dll. Active Server pages are implemented through an ISAPI application. Since the .idc extension is mapped to httpodbc.dll and the Internet Database Connector is an ISAPI application it to will run in an isolated process.

    What is the WAM

    Now that you have the basics of application isolation, lets see how it is handled. The Web application manager (WAM) implements process isolation. For each application namespace that is configured, there is a separate instance of the WAM. Think of the WAM as an executable that can load your ISAPI DLLs and direct requests from the IIS server to those calls. Since the WAM is an executable, it has it's own process space that is outside of the Internet Information Server. Each application namespace and the DLLs that are running within that application namespace are running in their own process space. The WAM, once started, does not close and restart for each request. It remains open to handle other requests. Once an instance of the WAM loads an ISAPI DLL, the DLL remains loaded so that it can handle other requests.

    How the WAM works

    When IIS 4.0 receives a request, it figures out what application namespace that the request is going to. If the request is going to an application namespace that is isolated and an instance of the WAM doesn't exist for this application namespace, then a WAM is created for that namespace. Once the WAM is created, it loads up the ISAPI DLL that supports that request. Once the request is handled, the WAM remains open and the ISAPI application remains loaded. When another request comes in for that same namespace, then the WAM is used. If for some reason the ISAPI DLL crashes and the WAM is closed. The next request for that namespace will open up a new instance of the WAM. This is the second big advantage of process isolation, not only does a bad ISAPI DLL not crash IIS, the next request is not inhibited by a previously failed request.

    Unloading the WAM

    IIS 4.0 also allows you to unload the instance of the WAM for a particular namespace. This is how:

    1. Open up the Internet Server Manager within MMC.
    2. Click on the directory that you want to begin your application namespace at.
    3. Right click on Properties .
    4. Depending on the type of directory click on either the Home Directory, Virtual Directory, or the Directory tab.
    5. From within the Application Setting click on the Unload button.
    6. Click on OK to exit.
    Unloading the WAM unloads both the instant of the WAM executable and all the ISAPI DLLs that that particular instant of the WAM has loaded. This is usefully when you want to replace components with out stopping the rest of the web server. Just unload the application space and replace the component.

    ISAPI Considerations

    Because of the WAM, some ISAPI DLLs that run well under IIS 3.0 will not run well when isolated under IIS 4.0. Specifically, ISAPI applications that cannot have two instances of the same DLL running at the same time. If you have two application namespaces that are both set to run isolated, and within the two namespaces you have the same ISAPI application, then you can possible have two instances of the ISAPI running. Once instance would be loaded by one instance of the WAM executable, and the other instance would be loaded by the other WAM executable. The NT operating system has no problem loading two different instances of the same DLL. However you need to take into consideration that there might be two open instances. Make sure not to lock resources like files or shared memory from within the ISAPI application.

    ODBC Connection Pooling Considerations

    Because ODBC Connection Pooling is turned on or off on the process level, running ISAPI applications in a separate process space means that you will have to turn connection pooling on within every ISAPI application. In IIS 3.0, where all ISAPI applications are run within the same process, having connection pooling turned on for Active Server pages meant that connection pooling was turned on for all other ISAPI applications as well. However, if you run your ISAPI applications in a isolated process space then you will need to turn connection pooling on from within each application. This also means that you can turn connection pooling on or off from within each application namespace. So you could have half of your Active Server page configured to be using connection pooling and the other half of your Active Server pages configured to not use connection pooling as long as your application namespaces are isolated.

    Active Server Page Considerations

    Besides the ODBC connection pooling, other attributes of Active Server pages can be configured per process, including the script timeout period, session handling and script caching. Unlike IIS 3.0, the WAM allows you to configure these options per application space, instead of per machine.

    Performance Considerations

    Applications running within the same process space as the Internet Information server will run faster then isolated processes. The WAM has additional overhead of communication between the Internet Information Server and itself when isolated. Plus, the WAM has a one-time startup cost of loading the WAM executable and loading the associated ISAPI applications. Besides the performance cost, there is a memory cost associated with running each WAM and the additional DLLs. However, isolated applications run faster, after the first request, then CGI executables.

    ISAPI Application Caching

    Like previous versions of IIS, IIS 4.0 allows you to cache ISAPI applications. This means that once loaded either by IIS or the WAM ISAPI, DLLs are not unloaded until either the server is stopped of the application namespace is unloaded. Because of the startup cost associated with loading a DLL, caching makes the response time faster then a CGI application that must load and unload executables.

    In IIS 3.0, you could configure all the ISAPI DLLs to either cache or not cache. In IIS 4.0 you can configure each namespace separately. This granularity allows you a greater degree of control. By default, each application namespace caches the ISAPI applications that reside within it. Here is how you turn caching off:

    1. Open up the Internet Server Manager within MMC.
    2. Click on the directory that you want to begin your application namespace at.
    3. While your directotry is selected, right click and choose Properties from the drop down menu.
    4. Depending on the type of directory click on either the Home Directory, Virtual Directory, or the Directory tab.
    5. From within the Application Setting click on the Configuration button.
    6. From with in the Application Configuration dialog click on the Application Mappings tab.
    7. Uncheck the box with the label Cache ISAPI Applications.
    8. Click on OK to exit the Application Configuration dialog.
    9. Click on OK to exit the properties dialog.

    Figure 02 : Turning Off Caching

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES