How does Task Parallel Library scale on a terminal server or in a web application?

Posted by Lasse V. Karlsen on Stack Overflow See other posts from Stack Overflow or by Lasse V. Karlsen
Published on 2010-05-02T11:16:38Z Indexed on 2010/05/02 11:27 UTC
Read the original article Hit count: 277

I understand that the TPL uses work-stealing queues for its tasks when I execute things like Parallel.For and similar constructs.

If I understand this correctly, the construct will spin up a number of tasks, where each will start processing items. If one of the tasks complete their allotted items, it will start stealing items from the other tasks which hasn't yet completed theirs. This solves the problem where items 1-100 are cheap to process and items 101-200 are costly, and one of the two tasks would just sit idle until the other completed. (I know this is a simplified exaplanation.)

However, how will this scale on a terminal server or in a web application (assuming we use TPL in code that would run in the web app)? Can we risk saturating the CPUs with tasks just because there are N instances of our application running side by side?

Is there any information on this topic that I should read? I've yet to find anything in particular, but that doesn't mean there is none.

© Stack Overflow or respective owner

Related posts about .net-4.0

Related posts about task-parallel-library