在多个应用程序域或频繁的应用recycing

在多个应用程序域或频繁的应用recycing

本文介绍了一个ASP.NET应用程序(意外),在多个应用程序域或频繁的应用recycing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我调试它看似随机失去一些静态字段的内容的ASP.NET应用程序。我做了一些简单的自定义日志记录(因为即使是log4net的片状),并发现该应用程序被加载成两个应用程序域。下面是从日志片段:

I'm debugging an ASP.NET application which is seemingly randomly losing the content of some static fields. I did some simple custom logging (because even log4net was flaky), and found out that the application is being loaded into two app domains. Here is a snippet from the log:

6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 1
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 2
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 3
6/27/2011 9:01:01 PM /LM/W3SVC/1/ROOT/MyApp-1-129537072581658334: log message 4
6/27/2011 9:01:02 PM /LM/W3SVC/1/ROOT/MyApp-4-129537072620628334: log message 5 <-
6/27/2011 9:01:02 PM /LM/W3SVC/1/ROOT/MyApp-4-129537072620628334: log message 6
6/27/2011 9:04:50 PM /LM/W3SVC/1/ROOT/MyApp-1-129537074647228334: log message 7
6/27/2011 9:04:50 PM /LM/W3SVC/1/ROOT/MyApp-1-129537074647228334: log message 8

时间/日期后该项目是目前应用的域名。

The item after the time/date is the current app domain name.

应用程序只是一个普通的ASP.NET(不MVC)应用程序处理一些AJAX请求并将它们传递给一串ASP.NET库。唯一不同寻常的是,图书馆之一,使用比特反射来查找一些类,然后实例化并运行它们放在单独的线程。不过,这并不与应用程序域做任何明确的。

The application is just a regular ASP.NET (not MVC) application handling some AJAX request and passing them to a bunch of ASP.NET libraries. The only unusual thing is that one of the libraries uses a bit of reflection to lookup some classes which then instantiates and runs them on separate threads. But it does not do anything explicitly with app domains.

顺便说一下,从日志文件的突出显示行来自ASP.NET应用程序本身(即,不从这些独立的线程中的一个)从一个ASPX处理程序。

By the way, the highlighted row from the log file comes from the ASP.NET app itself (i.e. not from one of those separate thread) from an ASPX handler.

我是间$ P $正确pting日志?如果是这样,有什么可以导致加载应用程序,并从多个应用程序域提供?

Am I interpreting the log correctly? If so, what can cause an application to be loaded and served from multiple app domains?

编辑:这个问题本质上是与此相关的:ASP.NET应用程序状态VS静态对象。然而,根据我今天所看到的,它似乎并不可能依赖于静态字段。我可以移动的一切Application对象,但我想同步将是一个有点麻烦。我越想越应用做了非标准的。

This question is essentially related to this one: ASP.NET Application state vs a Static object. However, based on what I've seen today, it does not seem possible to rely on static fields. I could move everything to the Application object, but I guess a synchronization would be a bit cumbersome. I'm more and more convinced the application does something non-standard.

编辑2:我没多一点点的调查,似乎总是有一个应用程序,应用程序域之间的关系1-1(这是我期望的那样)。所以,我认为我所看到的是回收再利用。

Edit 2: I did a little bit more investigation, and it seems that there is always a 1-1 relation between application and app domains (which is something I would expect). So I think that what I'm seeing is recycling.

修改3:经过一番更多的实验和闲逛,我启用IIS健康监测(基于http://blogs.msdn.com/b/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx),并发现该应用程序在快速连续两次启动它的实际工作颇令人费解这里是日志事件:

Edit 3: After some more experiments and poking around, I enabled IIS health monitoring (based on http://blogs.msdn.com/b/tess/archive/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles.aspx), and found out that the application is started twice in a quick succession. It's actuall quite puzzling. Here are the log events:

Event code: 1003
Event message: Application compilation is starting.
Event time: 6/28/2011 8:34:31 AM
Event time (UTC): 6/28/2011 3:34:31 PM
Event ID: d42336b18c264516a4ba5aa1e62df276
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
    Application domain: /LM/W3SVC/1/ROOT/MyApp-1-129537488697736549
    Trust level: Full
    Application Virtual Path: /MyApp
    Application Path: [snip]\MyApp\
    Machine name: US-SEA-R9759B2

Process information:
    Process ID: 7624
    Process name: w3wp.exe
    Account name: IIS APPPOOL\DefaultAppPool

----

Event code: 1001
Event message: Application is starting.
Event time: 6/28/2011 8:34:33 AM
Event time (UTC): 6/28/2011 3:34:33 PM
Event ID: f7fbecb1ba1a4a24833016cec47458c6
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
    Application domain: /LM/W3SVC/1/ROOT-2-129537488729428362
    Trust level: Full
    Application Virtual Path: /
    Application Path: [snip]\RootApp\
    Machine name: US-SEA-R9759B2

Process information:
    Process ID: 7624
    Process name: w3wp.exe
    Account name: IIS APPPOOL\DefaultAppPool

----

Event code: 1001
Event message: Application is starting.
Event time: 6/28/2011 8:34:40 AM
Event time (UTC): 6/28/2011 3:34:40 PM
Event ID: 07a3dc31e8804caca1ddc3b2101962e3
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
    Application domain: /LM/W3SVC/1/ROOT-3-129537488807712839
    Trust level: Full
    Application Virtual Path: /
    Application Path: [snip]\RootApp\
    Machine name: US-SEA-R9759B2

Process information:
    Process ID: 7624
    Process name: w3wp.exe
    Account name: IIS APPPOOL\DefaultAppPool

----

Event code: 1001
Event message: Application is starting.
Event time: 6/28/2011 8:34:40 AM
Event time (UTC): 6/28/2011 3:34:40 PM
Event ID: db304b519a084fa797fbcfe66fbb0b48
Event sequence: 1
Event occurrence: 1
Event detail code: 0

Application information:
    Application domain: /LM/W3SVC/1/ROOT/MyApp-4-129537488808502885
    Trust level: Full
    Application Virtual Path: /MyApp
    Application Path: [snip]\MyApp\
    Machine name: US-SEA-R9759B2

Process information:
    Process ID: 7624
    Process name: w3wp.exe
    Account name: IIS APPPOOL\DefaultAppPool

MyApp应用程序坐在另一个应用程序(RootApp)。我期望将有两个日志消息:MyApp的启动和RootApp出发

The MyApp application sits in another application (the RootApp). What I would expect would be two log messages: MyApp starting and RootApp starting.

推荐答案

你不小心设置工作进程中的应用程序池属性(性能选项卡)到2多少?

Did you accidentally set the number of worker processes in the AppPool Properties (Performance Tab) to 2?

在这些属性,也有可能是让你的应用程序池回收过于频繁,以数字或请求或任何这些回收设置的设定

In those properties, there could also be a setting that let's your AppPool recycle far too often, based on number or requests or any of those recycling settings

这篇关于一个ASP.NET应用程序(意外),在多个应用程序域或频繁的应用recycing的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 00:59