简体   繁体   English

调用Web服务如何导致死锁?

[英]How does calling web services lead to a deadlock?

This confusing MSDN article talks about how invoking a web service from an ASP.Net application can lead to a deadlock. 这篇令人困惑的MSDN文章讨论了如何从ASP.Net应用程序调用Web服务可能导致死锁。 I understand the part about each web service call needing a second thread to do IO completion. 我了解有关每个Web服务调用需要第二个线程来完成IO的部分。 I understand that there may not always be such a thread available, which means that the thread making the web service call will block and not make progress until such a thread becomes available. 我了解可能并不总是有这样的线程可用,这意味着进行Web服务调用的线程将阻塞,并且直到此类线程变得可用时才会取得进展。 But it seems to me that the web service calls that did get an IO thread will advance, and eventually both threads will be released back to the thread pool for use by the previously-blocked calls. 但是在我看来,确实获得了IO线程的Web服务调用将继续进行,最终两个线程都将释放回线程池,以供先前阻止的调用使用。 So where does the deadlock come from? 那么僵局从何而来? At the point that IIS kills the process, can you describe what the deadlocked threads are waiting for? 在IIS终止进程的时候,您能否描述死锁的线程正在等待什么?

This article is for .NET 1.0 / IIS 6 and doesn't really apply in newer versions of .NET/IIS. 本文适用于.NET 1.0 / IIS 6,并且不适用于更新版本的.NET / IIS。 The limits on the number of threadpool and IOCP threads are vastly higher in more recent versions of the framework, and the likelihood that you'll run into them is very, very small. 在较新版本的框架中,线程池和IOCP线程的数量限制要高得多,并且碰到它们的可能性非常非常小。

The basic problem that used to happen was that ASP.NET would limit the number of threads that it allowed anything to use and web requests were handled on I/O threads, so incoming web requests would consume all of the available threads and IO completion for outstanding (asynchronous) calls would be queued up behind the very web requests that were waiting for them. 过去经常发生的基本问题是ASP.NET会限制它允许使用的线程数,并且Web请求是在I / O线程上处理的,因此传入的Web请求将消耗所有可用线程和IO完成。未完成的(异步)调用将在等待它们的Web请求之后排队。

See also http://blogs.msdn.com/b/nicd/archive/2007/04/16/dissection-of-an-asp-net-2-0-request-processing-flow.aspx 另请参阅http://blogs.msdn.com/b/nicd/archive/2007/04/16/dissection-of-an-asp-net-2-0-request-processing-flow.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM