Search code examples
delphiiisiis-7.5page-lifecycleisapi

TISAPIApplication Lifetime in IIS 7.5 running on Windows Server 2008 RS2:


I am trying to figure out how to control the lifetime of a TISAPIApplication (written in Delphi XE) in IIS 7.5 - seeing unexpected behavior:

The ISAPI application pool and ALL LEVELS of IIS/ISAPI configuration are set to run with anonymous access under a specific system account, from the WebServer itself to the VD, appPool and specific dll - this NEVER changes. But each time a different user makes a request, or the same user opens a new browser session, the webApplication is reinitialized.

I expected that the webApp would be initialized only on first hit, or when IIS is reset or the app pool is recycled. This is the behavior I expected and that I NEED - the webApp should be a SINGLETON that spawns a thread for each new request, regardless of user or user sessions.

Clients are running IIS 8 or FireFox 6 (I believe this is irrelevant - differences between them I have observed are related to browser caching schemes, etc, not to the ISAPI application).

Clients are running Win XP SP3 or Win 7 64 - OS seems to have no impact on the behavior.

Monitoring/Feedback:

I am logging an entry in the event log each time the ISAPI app initializes, and returning a counter in a webPage indicating the number of requests the app has handled after initialization, as of that request.

I have worked with various 'advanced settings' at the IIS 7.5 application pool level - no luck so far.

Can anyone explain the behavior I am seeing, and how to go about changing it so that the TISAPIApplication instance behaves like a singleton?


Solution

  • Could it be that IIS is launching multiple w3wp.exe instances to load your ISAPI dll, and you get a webapplication initialization message from each when it starts? There's an application pool setting limiting the number of w3wp.exe's running alongside eachother. In some cases the best value for this setting is 1.