1

I'm looking at using some PLINQ in an ASP.NET application to increase throughput on some I/O bound and computationally bound processing we have (e.g., iterating a collection to use for web service calls and calculating some geo-coordinate distances).

My question is: should I be concerned that running operations like Parallel.ForEach will take threads away from processing other requests, or does it use a separate pool of threads (I've heard about something called I/O completion ports, but not sure how that plays into the discussion)?

Brandon Linton
  • 4,373
  • 5
  • 42
  • 63
  • 1
    You first mention PLINQ then talk about `Parallel.ForEach()`, so which one is it? `Parallel.ForEach()` is not part of PLINQ. – svick Sep 24 '12 at 18:23
  • 1
    Ah, I did not realize that, but I suppose my question is really for both - I'm just wondering if using either of these techniques in ASP.NET is always appropriate if the task is inherently parallelizable, or if the nature of threading in ASP.NET creates additional concerns. – Brandon Linton Sep 25 '12 at 00:11
  • I think there is no such thing as “always approprite”, there will always be edge cases. But yeah, you should understand how does PLINQ, `Parallel.ForEach()` and TPL in general interact with ASP.NET, so that you can choose the best option for your specific situation. – svick Sep 25 '12 at 00:31

1 Answers1

1

Parallel.ForEach will, at most, use one thread for as many cores as you have. The thread pool default maximum size is 250 times the number of cores you have. So you'll have to be really trying to run out of available threads.

Community
  • 1
  • 1
Tim Rogers
  • 21,297
  • 6
  • 52
  • 68
  • `Parallel.ForEach()` will use more than one thread per core if the `ThreadPool` will let it. – svick Sep 24 '12 at 18:27