Azure 网站 AppDomain 多次重启 [英] Azure Websites AppDomain many restarts
问题描述
我有一组在 Azure 网站 中运行的 asp.net 4.0 网站
I've a group of asp.net 4.0 Websites runing in Azure Websites
- 计算模式:标准
- 位置:北欧
- 容量自动调节:关闭
- 实例大小:大
- 实例数:1
响应时间很慢,流量正常,但我的日志显示很多AppDomain 关闭(一分钟超过 3 次).我的网站在应用程序启动期间加载缓存中的数据以快速响应所有后续请求,但如果 Appdomains 每次都重新启动,则无法提供可接受的响应时间.
The response time is very slow, the trafic is normal, but my log show many AppDomain shutdowns (more than 3 in one minute). My websites load data in cache during de Application_Start to give a rapid response to all subsequents requests but if the Appdomains restarts every time is impossible to give acceptable response times.
ShutdownReason 值很多:
- 配置变更
- 托管环境
- CodeDirChangeOrDirectoryRename
- BinDirChangeOrDirectoryRename
- BrowsersDirChangeOrDirectoryRename
这没有意义,因为我没有更改这些文件夹中的任何文件.
This have no sense because I've not changed any file in these folders.
我已经在免费模式下测试了其中一个网站,运行速度非常快,并且没有任何意外的 AppDomain 重启.
I've tested one of these sites in a free mode running very fast and without any unexpected AppDomain restart.
谢谢.
更新:
我已将此代码包含在 Application_Start 中,未检测到任何文件更改,并且 AppDomain 再次重新启动,一次又一次...
I've included this code in the Application_Start, no file changes have been detected and the AppDomain is restarting again, and again...
var monitorPath = HostingEnvironment.MapPath("~/");
Application.Add("watcher", new FileSystemWatcher(monitorPath));
fsw = (FileSystemWatcher) Application["watcher"];
fsw.EnableRaisingEvents = true;
fsw.IncludeSubdirectories = true;
fsw.Changed += fsw_Changed;
fsw.Created += fsw_Created;
fsw.Deleted += fsw_Deleted;
fsw.Renamed += fsw_Renamed;
2013 年 7 月 15 日更新:
使用 ScottGu 文章中的代码 http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx
using the code from the ScottGu article http://weblogs.asp.net/scottgu/archive/2005/12/14/433194.aspx
我已经记录了这个:
_shutDownMessage=Directory rename change notification for 'C:\DWASFiles\Sites\my-sitename\VirtualDirectory0\site\wwwroot'.
File Change Notification Error in wwwroot
HostingEnvironment initiated shutdown
Change Notification for critical directories.
File Change Notification Error in App_GlobalResources
Change Notification for critical directories.
File Change Notification Error in bin
Change Notification for critical directories.
File Change Notification Error in App_Browsers
Change Notification for critical directories.
File Change Notification Error in App_Code
Change Notification for critical directories.
File Change Notification Error in App_WebReferences
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
CONFIG change
File Change Notification Error in C:\DWASFiles\Sites\my-sitename\VirtualDirectory0\site\wwwroot
CONFIG change
File Change Notification Error in
HostingEnvironment caused shutdown
File Change Notification Error in
Change Notification for critical directories.
File Change Notification Error in App_LocalResources
Change Notification for critical directories.
File Change Notification Error in App_LocalResources
CONFIG change
_shutDownStack= at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownWithoutDemand()
at System.Web.HttpRuntime.ShutdownAppDomain(String stackTrace)
at System.Web.HttpRuntime.OnCriticalDirectoryChange(Object sender, FileChangeEvent e)
at System.Web.FileChangesMonitor.OnSubdirChange(Object sender, FileChangeEvent e)
at System.Web.DirectoryMonitor.FireNotifications()
at System.Web.Util.WorkItem.CallCallbackWithAssert(WorkItemCallback callback)
at System.Web.Util.WorkItem.OnQueueUserWorkItemCompletion(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
2013 年 7 月 19 日更新:
指标 Data-In 非常高,与请求指标无关,但是当我配置设置 fcnMode="Disabled" 时,data-In 立即下降到正常值符合交通.
The metric Data-In is very high and has no relation with the requests metric, but when I configure the setting fcnMode="Disabled" the data-In immediately down to normal values accord with the traffic.
推荐答案
在 asp.net 4.5 中使用新设置 fcnMode(似乎在 4.0 中有效)AppDomain 停止重启
Using the new setting fcnMode in asp.net 4.5 (seems to work in 4.0) the AppDomain stops restarting
<httpRuntime fcnMode="Disabled" />
但是,现在的问题是为什么 azure 网站中的 FileChangesMonitor(至少在我订阅的网站中)给出这个 _shutDownMessage:
But, the question now is why the FileChangesMonitor in azure Websites (at least in the websites in my subscription) give this _shutDownMessage:
File Change Notification Error in wwwroot
HostingEnvironment initiated shutdown
Change Notification for critical directories.
File Change Notification Error in App_GlobalResources
Change Notification for critical directories.
File Change Notification Error in bin
Change Notification for critical directories.
File Change Notification Error in App_Browsers
...
更新:
原因是 SMB 中的一个错误,该错误仅影响北欧位置.
The cause was a bug in SMB that was affecting only the location North Europe.
这篇关于Azure 网站 AppDomain 多次重启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!