views:

283

answers:

2

I just watched the last Channel 9 vid on the upcoming parallel extensions to .NET. How would you use this in a web app? I'm specifically thinking of using the parallel Linq extensions against a SQL db. Would this makes sense to use as a way to speed up your data access layer in a multi-user server app? What are the issues (aside from the obvious thread safety issues using static collection types)?

+2  A: 

Parallel LINQ is primarily intended to work against in-memory collections, I believe. How were you anticipating using it against your database?

Given that webapps are naturally pretty parallel (in terms of separate requests executing on separate threads etc) I suspect that PLINQ won't really apply to it much.

Jon Skeet
Makes sense, kinda what I thought. Was just excited about PLINQ...
Codewerks
Within each request PLINQ is perfectly applicable, with nice performance gains.
Mauricio Scheffer
@mausch: If you regularly only have one request being processed and each request takes a lot of CPU, then it's appropriate. I doubt that it's relevant to most webapps though - and not "against a SQL db" as stated in the question.
Jon Skeet
@Jon: If fear that developers may not heed what you are saying and end up causing performance problems in web apps. The same thing happened with parallel query in Oracle. It is mainly a single user thing.
RussellH
+3  A: 

I think this paragraph extracted from this article explains the usage of PLINQ-to-SQL:

LINQ-to-SQL and LINQ-to-Entities queries will still be executed by the respective databases and query providers, so PLINQ does not offer a way to parallelize those queries. If you wish to process the results of those queries in memory, including joining the output of many heterogeneous queries, then PLINQ can be quite useful.

As for the usage of PLINQ in a web app, if the request requires many in-memory calculations in witch PLINQ might be useful (like if you have several data sources that you'd like to query together) I see no problems in using it.

bruno conde
Thanks for the link! No pun intended...or maybe? ;)
Codewerks