3

是否有人知道 IIS 7 中的任何设置会强制它在每个请求中使用单个线程,并且不允许它在请求期间切换线程?还是回到旧的线程模型?

我们的问题是整个请求,从头到尾使用到不同数据库的多个连接,我们希望通过使用 TransactionScope 来保证数据完整性(它从轻量级事务开始,然后在建立第二个连接后提升为分布式事务) .

我们每个请求需要一个线程的原因是,当您尝试在与启动它的线程不同的线程上处理事务时,它会引发异常,说明它必须在启动它的同一线程上处理。然后事务泄漏,没有任何东西被提交,它慢慢地让机器停止运转。

4

2 回答 2

1

在我们支持的 .net 版本(当时是 4.0)中没有办法做到这一点。所以我们被迫放弃分布式事务覆盖。

理论上你可以用.net 4.5.1 TransactionScopeAsyncFlowOption

于 2014-06-25T14:17:51.943 回答
0

To limit the number of threads for per asp.net worker process you can set the maxWorkerThreads which configures the maximum number of worker threads to use for the process on a per-CPU basis. I don't remommend to configure only one thread for each asp.net worker process. That obviously hits the performance.

Configuring the worker threads for application pool  appear to there are several approaches. The first is to set the processModel element in the web.config file:

http://msdn.microsoft.com/en-us/library/7w2sway1.aspx

 The second is to set the aspnet.config file(you can find the aspnet.config file with the path either  "c:\Windows\Microsoft.NET\Framework64\v2.0.50727" or "C:\Windows\Microsoft.NET\Framework64\v4.0.30319"):

http://msdn.microsoft.com/en-us/library/dd560842.aspx

The last approach you can check the first reference you mentioned at the initial post and the reference below is useful complementarity:

http://www.iis.net/ConfigReference/system.applicationHost/applicationPools/add

Credit:http://forums.iis.net/t/1188351.aspx

于 2013-09-29T03:23:30.090 回答