Azure Web Role “warm up” strategies [closed]

爷,独闯天下 提交于 2019-12-02 15:38:54

We use a combination of a couple of those answers and it works perfectly well for us, they're very quick to change and test however, it seems to cover all bases.

public override bool OnStart()
{
    ServicePointManager.DefaultConnectionLimit = 12;
    if(!RoleEnvironment.IsEmulated)
    {
        using(ServerManager serverManager = new ServerManager())
        {
            foreach (var app in serverManager.Sites.SelectMany(x => x.Applications))
            {
                app["preloadEnabled"] = true;
            }
            foreach (var appPool in serverManager.ApplicationPools)
            {
                    appPool.AutoStart = true;
                    appPool["startMode"] = "AlwaysRunning";
                    appPool.ProcessModel.IdleTimeout = TimeSpan.Zero;
                    appPool.Recycling.PeriodicRestart.Time = TimeSpan.Zero;
            }
            serverManager.CommitChanges();
        }
    }
    return base.OnStart();
}

Have you considered using the Azure endpoint monitoring to both monitor and trigger your role to respond every 5 minutes? It's built into Azure and there's no code needed.

http://azure.microsoft.com/en-us/documentation/articles/web-sites-monitor/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!