???? ID: 821268 - ????? ???????: 05 ?????? 2010 - ??????: 2.0

Contention, ???? ????????, ?? ?? ?? asp.NET ??????????? ?? ??? ???? ?????? ????? deadlocks

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.

?? ????? ??

??? ?? ??????? ???? | ??? ?? ??????? ????

?????

?? ???? ??? ???? ?? ??? XML ??? ???? ?? ??? asp.NET ?????????, contention, ???? ????????, ?? deadlocks ????? ?? ???? ??? ??????? ?? ??????? ?? ???? ?? ?? ?????? ???????? (?? "????") ?? ????? ?? ????????? ???? ?? ??? ???? ???? ??? ??? ??? ??? deadlock suspected ??, ????? ????????? ????????? ?? ???? ??? ????????? ????? ??? ??? ???? ????? ????? ??????? ?? ???? ???
  • ??? ?? Microsoft ??????? ?????????? ???????? (IIS) 5.0 ?? ????? ?? ??? ???, ?? ???? ????? ????? ??????? ????????? ????? ??? ???:

       Event Type:     Error
       Event Source:   ASP.NET 1.0.3705.0
       Event Category: None
       Event ID:       1003
       Date:           5/4/2003
       Time:           6:18:23 PM
       User:           N/A
       Computer:       <ComputerName>
       Description:
          aspnet_wp.exe  (PID: <xxx>) was recycled because it was suspected to be in a deadlocked state.
          It did not send any responses for pending requests in the last 180 seconds.

  • ??? ?? IIS 6.0 ?? ????? ?? ??? ???, ?? ???? ????? ????? ??????? ????????? ????? ??? ???:

       Event Type:     Warning
       Event Source:   W3SVC-WP
       Event Category: None
       Event ID:       2262
       Date:           5/4/2003
       Time:           1:02:33 PM
       User:           N/A
       Computer:       <ComputerName>
       Description:
          ISAPI 'C:\Windows\Microsoft.net\Framework\v.1.1.4322\aspnet_isapi.dll' reported itself as
          unhealthy for the following reason: 'Deadlock detected'.

  • ??? ?? IIS 6.0 ?? ????? ?? ??? ???, ?? ???? ????? ????? ??????? ?????? ????? ??? ???:

       Event Type:     Warning
       Event Source:   W3SVC
       Event Category: None
       Event ID:       1013
       Date:           5/4/2003
       Time:           1:03:47 PM
       User:           N/A
       Computer:       <ComputerName>
       Description:
          A process serving application pool 'DefaultAppPool' exceeded time limits during shut down.
          The process id was '<xxxx>'.

?? ?? ??????? ?? ???? ?? ????? ????? ?????? ????? ?? ?? ??? ???? ?? ???HttpWebRequest.GetResponse????:
? System.InvalidOperationException: ???????? ?? ????? ???? ?? ??? ThreadPool ???????? ??? ???? ???????? ????? ??????? ???? ??. ?
?? ??????? ??? ????? ????? ?????? ????? ?? ??????? ?? ???? ??:
? HttpException (0x80004005): ?????? ???? ??? ?? ???. ?
???:????????? ????? ?? ??? ?? ???? ?? ???? ????HttpWebRequest?????? ?????

????

?? ?????? ??????? ?? ???? ?? ??????? asp.NET ????? ????? ?? ??????? ????? ??????? ??? ???????? ?? ????????? ???? ?? ??? ????? ?? ???? ??? ?? ?? ?????? ?? ????? ???? ???

??????????, ?? ??? ???? ?? ??? ???? ??? ???? ????? ???? ?? ?? ?????? ????? ?? ??? ?? ????????? ???? ?? ??? ?? ????? ????? ?? ??? ???? ?? ?????? ?? ??????? ???? ?? ??? ?? ????? ????? ?????? ???????, ??? ?????? ?????????????? ?? ?? ?????????? ?? ???????? ??, ?? ??? ?? ???? ?? ????? ?? ??? ??? ?? many ?? ????? ?? ?? ??????? ????? ???????? ?????, ?? ?? ???? ??? exhaust ???????? ThreadPool ?? ?? ?? ??? ??? ?????? ??? ???? ??? ???

?????? ?? ???, suppose ?? ThreadPool 10 ????? ????? ?? ??? ????? ??, ?? ??? 10 ????? ????? ????????? ??? ?? ????????? ???? ?? ??? ??? ?????? ?? ????????? ?? ??? ?? ?? ??????? ??? ???? ????? ?????? ?? ???? ?? ?? ??? ????? ?????? ?? ThreadPool ???? ?? ??? ?????????? ?? ????? ??? ?? ??? ??????? ?????? ????????? ???? ?? ???? ????

???? ???? ??????? ????? contention ?? ??maxconnection???????? ??System.Net??????? ?? ?????? ?? ????? ???? ?? ??? ??? ????? ????? ???? ??? ??????????, ?? ???? ??? ?? ??? ??? ????????? ???????, ?? ????????? ?? ?????? ???? ?? ??? ??? ??? IP ??? ?? ?? ??? ??? ?? ?????? ????? ?? ???, ??? ??????? ?? ???? ?? ??? ?????? ??????? ?? ????????? ?????

????????

?? ???????? ?? ?? ???? ?? ??? ?? ????? ???????? ?? ???? ?????? ?? ??????? ??? ???? ?? ??? ???? Machine.config ????? ??? ???? ?? ???? ???:
  • maxWorkerThreads
  • minWorkerThreads
  • maxIoThreads
  • minFreeThreads
  • minLocalRequestFreeThreads
  • maxconnection
  • executionTimeout
?? ???????? ?? ?????? ???????????, ?? ??? ????? ?????:
  • ???? ????? CPU 12 ???? ?? ??? ?? ?? ??? ?? ????????? ?? ???? ??? ?? asp.NET ???????? ?? ?????? ????? ?????
  • ??? ???? callbacks ThreadPool ??? ??????? ????? ?? ????? ???? ?? ?????? ???
  • ?? ??? ??? ???? ??? ?? ??? ????maxconnections????????? ???? ??? ?? IP ??? ?? ????? ??? ???? ??? ?? AppDomains ?? ?????? ?? ?????? ?????
???:??????? ???? ?? ??? CPU ?? ????? 12 asp.NET ???????? ?? ?????? ?? ????? ???? ?? ??? ?? little arbitrary ??? ???????, ?????? ??????????? ?? ??? ?? ??? ???? ?? ??? ?? ???? proved ???

maxWorkerThreads, ??maxIoThreads

ASP.NET uses the following two configuration settings to limit the maximum number of worker threads and completion threads that are used:
<processModel maxWorkerThreads="20" maxIoThreads="20">
ThemaxWorkerThreadsparameter and themaxIoThreadsparameter are implicitly multiplied by the number of CPUs. For example, if you have two processors, the maximum number of worker threads is the following:
2*maxWorkerThreads

minFreeThreads, ??minLocalRequestFreeThreads

ASP.NET also contains the following configuration settings that determine how many worker threads and completion port threads must be available to start a remote request or a local request:
<httpRuntime minFreeThreads="8" minLocalRequestFreeThreads="8">
If there are not sufficient threads available, the request is queued until sufficient threads are free to make the request. Therefore, ASP.NET will not execute more than the following number of requests at the same time:
(maxWorkerThreads*number of CPUs)-minFreeThreads
???:TheminFreeThreadsparameter and theminLocalRequestFreeThreadsparameter are not implicitly multiplied by the number of CPUs.

minWorkerThreads

As of ASP.NET 1.0 Service Pack 3 and ASP.NET 1.1, ASP.NET also contains the following configuration setting that determines how many worker threads may be made available immediately to service a remote request.
<processModel minWorkerThreads="1">
?? ?????? ?????? ????????? ??????? ?? ???? ????? ?? ?? CLR ??????? "?????-????????" ???????? ?? ???? ?? ????? ????? ?? ????? ?? ???? ??? ?? ?????? ?? ???? ?? suddenly ???? asp.NET ?????? ?????? ?? ???? ???? ??? ?????, ?????? ??????? ?? ???, ?? ???? ??? ?? ?? ???? ???????? ?? ?????? ??? ?? sudden rise ???? ??? ?? ?? sudden burst slow-down ?? ?? ???? ???? ?????? ???? ?? ??? asp.NET ????? ???? ??? ?? ??? ??????? ???minWorkerThreads???????? 1 ??? We recommend that you set the value for theminWorkerThreadsparameter to the following value.
minWorkerThreads = maxWorkerThreads / 2
???????? ??? ??,minWorkerThreadsparameter is not present in either the Web.config file or the Machine.config file. This setting is implicitly multiplied by the number of CPUs.

maxconnection

Themaxconnectionparameter determines how many connections can be made to a specific IP address. The parameter appears as follows:
<connectionManagement>
    <add address="*" maxconnection="2">
    <add address="65.53.32.230" maxconnection="12">
</connectionManagement>
The settings for the parameters that are discussed earlier in this article are all at the process level. ???????,maxconnectionparameter setting applies to the AppDomain level. ???????? ??? ??, ?? ?????? AppDomain ???? ?? ???? ???? ?? ??????? ??? ???? ??? ?? ????????? ?? ?????? ?? ??????? IP ??? ???? ?? ??? ???????? AppDomain ?? ???? ????????? ????

executionTimeout

ASP.NET ?????? ???????? ??? ?? ????? ???? ?? ??? ????? ??????????? ?????? ?? ????? ???? ??:
<httpRuntime executionTimeout="90"/>
?? ???? ?? ????? ?? ?? ???? ?? ??? ?? ???? ???Server.ScriptTimeout????

???:??? ?? ?? ??? ?????executionTimeout???????? ?? ???, ???? ?? ??? ???? ?? ?? ??????? ???? ?? ???processModel responseDeadlockInterval???????? ???????

?????????

?? ?????? ??? ???????? ???????? ??? ??????????? ?? ??? ??? ???? ?? ???? ??? ???????, ???????? ????? ????? ??? ?? ???? ?? ?? ??????? ??????? ????? ?? ????

??? ?? ?? ??? ???? ??? ???? ?? ??? ??? ??? IP ??? ?? ???????? ASPX ????? ???? ???, ?? Microsoft ??????? ???? ?? ?? ?? ????? ??????????? ???????? ?? ????? ????:
  • ????? ?? ??? ????maxWorkerThreads???????? ??maxIoThreads???? ?? ??? ????????100.
  • ?? ??? ?? ??? ????maxconnection???? ?? ??? ????????12 *N(????N?? ?????? ?? ?? ???? CPU)?
  • ????? ?? ??? ????minFreeThreads???? ?? ??? ????????88 *N??minLocalRequestFreeThreads???? ?? ??? ????????76 *N.
  • ?? ??? ?? ??? ????minWorkerThreads???? ?? ???50. ??? ????,minWorkerThreads???????? ??? ?? ??????????? ????? ??? ???? ??? ?? ??? ??? ?????? ?????
?? ?????????? ?? ??? CPU ?? ?????? ???? ????? ?? involves ?? ?????? ????? ????? ???? ?? ??????? ??? CPU ?? ?????? ?? ???????????? ???? ??N. ?? ???????? ?? ??? ??? ???? hyperthreading ????? ???? ??? ??, ?? ?? ????? ???? ????? ??????? CPU ?? ?????? ????? CPU ?? ?????? ?? ????? ??? ?????? ?? ???, ??? ??? ?????-???????? ????? hyperthreading ????? ???? ??? ??, ?? ??? ??? ?? ?? ???N????? ??? ???? ?????8?? ????4.

???:?? ?? ?? ??????????? ?? ????? ?? ?? ???? ??? ????????? ?????? 12 asp.NET ?????? CPU ?? ????? ?? ?? ??? ??? ???????100-88 = 12. ?????, ?? ?? ?? 88 *N????? ????? ?? 88 *N????? ????? ??????? ???? ????? (??? ??? ???? callbacks ?? ??? ?? ??? ???) ?? ??? ?????? ????

?????? ?? ???, ???? ??? ??? ????? ?? ??? ???????? ?? hyperthreading ????? ??? ?? ??????? ?? ?????? ??, ???? ???? ????? ????? ??? ?? ?? ???? ??? ???????? ??????????? ???????? ?? ????
<system.web>
	<processModel maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/>
	<httpRuntime minFreeThreads="704" minLocalRequestFreeThreads="608"/>
</system.web>

<system.net>
	<connectionManagement>
		<add address="[ProvideIPHere]" maxconnection="96"/>
	</connectionManagement>
</system.net>

??, ?? ?? ?? ??????????? ?? ????? ????, 12 ??????? ?????? CPU ?? ????? ????? AppDomain ???????? ?? ??? IP ???? ?????, ?????????? ???????? ??? ???? ?? contention ?? ???? ??, ?????? ??????? ?? ??? ????????? ?? ?? ??? ??? ?? ThreadPool exhausted ???? ??:
  • ??? (AppDomain) ???? ?? ????????? ?? ????? ???? ???
  • ??? ASPX ????? ?? ??? ???????? ?????? ?? ?? ??? ???? ?????? ????? ???
  • ??? ?????? ???? ?? ??? ???? IP ??? ????
??? ??, ?? ?? ?? ??????????? ?? ????? ???????? ?? ?? ????? ??? ?? ???? ?? ?? ?????? ???? ?????? ????? ???? ???? ???????:
  • ?????? ???? ?? ??? ?? ?? ???? IP ??? ????
  • ?????? ?? ?????????????? (302 ?????? ???) ????
  • ?????? ??? ??????? ?? ???????? ???
  • ?????? ??? ?? ?? ???? AppDomains ?? ??? ?? ????
?? ?????????? ??? ?? ??? ????? ????? ?? ?? ??? ?? ??? ?? ????? ???? ?? ???maxconnection???????? ?? ?? ??? ???? ???minFreeThreads???????? ??minLocalRequestFreeThreads?????????

??????

?? ??????? ??????? ?????? ??..

???? ???????

??? ?? ???? ???????? ?? asp.NET ?? ??? IIS 7.0 ?? contention ? ??? ???, ?? ????? Microsoft blogs ?????:

IIS 7.0 ?? 6.0 ?? asp.NET ????? ?? ?????
HTTP://blogs.MSDN.com/tmarq/Archive/2007/07/21/ASP-NET-thread-usage-on-IIS-7-0-and-6-0.aspx (http://blogs.msdn.com/tmarq/archive/2007/07/21/asp-net-thread-usage-on-iis-7-0-and-6-0.aspx)
IIS 7.0 ??? ASP.NET ????
HTTP://blogs.MSDN.com/webtopics/Archive/2009/02/13/ASP-NET-hang-in-IIS-7-0.aspx (http://blogs.msdn.com/webtopics/archive/2009/02/13/asp-net-hang-in-iis-7-0.aspx)

??????

???? ??????? ?? ???, ????? Microsoft ?????? ??????? (MSDN) ??? ???? ?? ????::
HTTP://msdn2.Microsoft.com/en-us/library/ms998549.aspx (http://msdn2.microsoft.com/en-us/library/ms998549.aspx)

???? ???? ???? ??:
  • Microsoft .NET Framework 2.0
  • Microsoft ASP.NET 1.1
  • Microsoft ASP.NET 1.0
??????: 
kbprb kbmt KB821268 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:821268  (http://support.microsoft.com/kb/821268/en-us/ )