By default in IIS, if no request is sent to the application for 20 minutes, the application will be suspended and if a request is sent to the application again, it will respond to the first request with a slight delay. Due to re-running the application. In applications with a large number of requests, this may not be very important, but if you have an application to do background work, it will cause the system to crash. Because no request is sent to the application and background work is stopped. To solve this problem, you need to change the settings related to the Application Pool and Web Site for the desired application on IIS

1. Enable Application initialization: In IIS 8.0, a module called Application initialization has been added. The function of this module is to heat the system. This module allows you to perform basic tasks such as database connections, loading modules, etc. at the very beginning of the program before the first request arrives :). 

To activate this module, you must enable the Application initialization option in the following path:

Turn Windows features on or off > Internet Information Services > World Wide Web Services > Application  Development Services

The way this module works is that you introduce a path to it (usually a record is read from the database in this path) and when your ApplicationPool is run it sends a request to the registered path to get the so-called initial tasks for the path. System startups should not be delayed until the first request is sent to the program. To do this, you must enter the following commands into the system.webServer tag in the web.config file:

    <applicationInitialization doAppInitAfterRestart="true"
    skipManagedModules="true" >
      <add initializationPage="/Ping" />
    </applicationInitialization>

Using the above commands, we specify that after the ApplcationPool is started, it sends a "/Ping" request to the path entered in the initializationPage parameter, in which a request to the database, the initial setup of services, takes place. Then you need to set the Application Pool Start Mode value to AlyawsRunning and the WebSite PreLoad Enebled value to true to do this automatically. This always sends a request to warm up the application when the application is started or restarted :).

2 - Set the Idle Time-out value for ApplicationPool to 0.

You can also use a script written by Mr. Vahid Nasiri to keep applications alive in IIS

:)

Powered by Froala Editor

Comments