Is AsParallel () a good practice in a web environment?

I have no doubt that for client applications, AsParallel () will bring some of the performance benefits. But what if I use it in a web environment. Let's say I have a widget infrastructure that iterates over all widgets to get its data and output the result. Will it parallelize big no?

I have doubts about using AsParallel () in this scenario. What if I have a large number of visitors to my site, will IIS not use multiple threads to handle all requests? Will there be any blocking problems after some time, or will threads die because all processors are in use?

Is it just a thought, what do you think of it?

+4
source share
2 answers

I have doubts about using AsParallel () in this scenario. What if I have a large number of visitors to my site, I will not use IIS multiple threads to handle all requests?

This, but, as an AsParallel () option, (potentially) use mutiple threads to cycle through each item in the collection for this request. This will potentially reduce the response time for each request that uses it. It is difficult to say whether this will help you or hinder you, depending on the size of the collection of objects, etc. Verily, you will have to try to see it.

Won't there be lock problems presented after while, or are threads dying because all processors are being used?

Hard to say. It depends on which part of the server is currently in use. If you bind the server 99%, you are likely to have problems (but again, using the AsParallel () option is likely to be the least of your worries.)

+4
source

I would actually test to see if AsParallel will win. In performance tests, I worked against some code, in simple and medium cases, no real performance benefit was obtained using AsParallel (in fact, it was really worse due to the additional overhead of creating threads and sorting values).

In addition, depending on how the threads are created, you can use more threads from the ASP.NET thread pool instead of other threads.

+1
source

Source: https://habr.com/ru/post/1308669/


All Articles