Is it Possible To Perform Concurrent Processing in ASP.NET 4?
I'd like to ask you is it possible to use parallel programming in ASP.NET 4? For example PLINQ.
(Because all hosting servers are multi-cores now and wi开发者_运维知识库ll it give better perfomance?)
Yes it's possible. But in doubt it makes sense in the most cases. ASP.NET is already highly parallelized, as every request works in it's own thread. If you spin off other threads to do some of the work, that would create overhead. This overhead will slow down other threads working on other requests. Then again, you will introduce another overhead when synchronizing the results to finish the request. Also this overhead will probably slow down the time required to answer the request.
There might be scenarios where that actually would help increase overall performance, but I think in general it's not worth it.
Of course only stress tests with both approaches would make sure if its more efficient to go with PLINQ or to not use it.
The answer is YES.
Why would you think otherwise? (Hence the sarcastic comments.)
Note, unless you take special steps every HTTP request needs to be completed on the thread that starts serving it. The special steps involve telling ASP.NET to use asynchronous processing for pages which allows a response to be created and the request to be completed on a different threads (with, potentially, intermediate processing other other threads). If you use TPL (including PLINQ) from the request's original thread this is not a problem.
精彩评论