Windows azure or IIS slows down under heavy load

I have a simple personal MVC4 web application hosted on Windows Azure.

This web application is very little used, the initial call is very slow, especially when I tried to click in the morning.

I suspect IIS was asleep and needed to wake up. I found this article and mention that this is a bug in IIS http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/8b3258e7-261c-49a0-888c-0b3e68b2af13 , which required installation in IIS, but my web application is hosted in Azure, is there any way to make some kind of customization in the Web.config file?

All subsequent calls are quick.

Here is my personal page. javierdelacruz.com

Thanks.

+1
source share
1 answer

Two options:

  • Launch tasks
  • OnStart Code

For startup tasks see this link .

For OnStart code, try this function (this function does a few more things):

private const string _web_app_project_name = "Web"; public static void SetupDefaultEgConfiguration(int idleTimeoutInMinutes = 1440, int recycleTimeoutInMinutes = 1440, string appPoolName = "My Azure App Pool", bool enableCompression = true) { if (!RoleEnvironment.IsEmulated) { Trace.TraceWarning("Changing IIS settings upon role OnStart. Inputs: ({0}, {1}, {2}, {3}", idleTimeoutInMinutes, recycleTimeoutInMinutes, appPoolName, enableCompression); // Tweak IIS Settings using (var iisManager = new ServerManager()) { try { var roleSite = iisManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_" + _web_app_project_name]; if (enableCompression) { //================ Enable or disable static/Dynamic compression ===================// var config = roleSite.GetWebConfiguration(); var urlCompressionSection = config.GetSection("system.webServer/urlCompression"); urlCompressionSection["doStaticCompression"] = true; urlCompressionSection["doDynamicCompression"] = true; Trace.TraceWarning("Changing IIS settings to enable static and dynamic compression"); } //================ To change ApplicationPool name ================================// var app = roleSite.Applications.First(); app.ApplicationPoolName = appPoolName; //================ To change ApplicationPool Recycle Timeout ================================// var appPool = iisManager.ApplicationPools[app.ApplicationPoolName]; appPool.Recycling.PeriodicRestart.Time = new TimeSpan(0, recycleTimeoutInMinutes, 0); //================ idletimeout ====================================================// var defaultIdleTimeout = iisManager.ApplicationPoolDefaults.ProcessModel.IdleTimeout; var newIdleTimeout = new TimeSpan(0, idleTimeoutInMinutes, 0); if ((int)newIdleTimeout.TotalMinutes != (int)defaultIdleTimeout.TotalMinutes) { appPool.ProcessModel.IdleTimeout = newIdleTimeout; } // Commit the changes done to server manager. iisManager.CommitChanges(); } catch (Exception e) { Trace.TraceError("Failure when configuring IIS in Azure: " + e.ToString().Take(63000)); } } } } 

The source and some details for the function that I included here are some dependencies that you probably need to fulfill.

+1
source

All Articles