Is anyone aware of any setting in IIS 7 that will force it to use a single thread per request, and not allow it to switch threads during a request? Or go back to a legacy thread model?
Our problem is the entire request, beginning to end uses multiple connections to different databases and we want to guarantee data integrity by using TransactionScope (which starts as a light weight transaction, then is promoted to a distributed transaction, once a second connection is established).
The reason we need a single thread per request, is when you attempt to dispose a transaction on a thread different than the thread that started it, it throws an exception stating it must be disposed on the same thread that started it. Then the transaction leaks, and nothing gets committed, and it slowly brings the machine to a grinding halt.
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
There was no way to do this in the version of .net that we supported (4.0 at the time). So we were forced to drop the distributed transaction coverage.
In theory you can do it with .net 4.5.1 TransactionScopeAsyncFlowOption
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With