Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The default timeout for IIS is 20 minutes. What this means is if your ASP.NET application does not receive any new requests for 20 minutes, it will shut down the worker process. It can take a considerable amount of time to warm up the process from nothing - loading assemblies into memory, precompilation, etc.</p> <p>(<em>Edit</em>: I put together a simple helper class that resolves the standard timeout issue - basically the web application "pokes" itself every so often to keep the process alive. The ideal approach is to change the setting in IIS, but for servers where this is not possible, my class works quite well. - <strong>Code at the bottom</strong>)</p> <p>While the worker process is still alive, it should not be deprioritized. Certainly not as quickly as you're describing. It is possible you could relying on items that are cached for a very short period of time, and are falling out when they've not been requested for more than a few seconds. Without knowing more about the details of your application, it's impossible to say.</p> <p>As usual, profiling your application is the only way to yield concrete information. Using a product like <a href="http://www.red-gate.com/products/ants_performance_profiler/index.htm" rel="nofollow noreferrer">ANTS</a> will help you determine where in the code your application is spending the most time, so you can isolate where the "hang" is occurring.</p> <pre><code>public class KeepAlive { private static KeepAlive instance; private static object sync = new object(); private string _applicationUrl; private string _cacheKey; private KeepAlive(string applicationUrl) { _applicationUrl = applicationUrl; _cacheKey = Guid.NewGuid().ToString(); instance = this; } public static bool IsKeepingAlive { get { lock (sync) { return instance != null; } } } public static void Start(string applicationUrl) { if(IsKeepingAlive) { return; } lock (sync) { instance = new KeepAlive(applicationUrl); instance.Insert(); } } public static void Stop() { lock (sync) { HttpRuntime.Cache.Remove(instance._cacheKey); instance = null; } } private void Callback(string key, object value, CacheItemRemovedReason reason) { if (reason == CacheItemRemovedReason.Expired) { FetchApplicationUr(); Insert(); } } private void Insert() { HttpRuntime.Cache.Add(_cacheKey, this, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.Normal, this.Callback); } private void FetchApplicationUrl() { try { HttpWebRequest request = HttpWebRequest.Create(this._applicationUrl) as HttpWebRequest; using(HttpWebResponse response = request.GetResponse() as HttpWebResponse) { HttpStatusCode status = response.StatusCode; //log status } } catch (Exception ex) { //log exception } } } </code></pre> <p>Usage (perhaps in App_Start):</p> <pre><code>KeepAlive.Start("http://www.yoursite.com/"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload