2

I'm using Visual Studio 2012 .Net 4.5, MVC 4, C#

On the server, there is a task to redirect the user to a site. It is done after analysing some data that might take some time. I want the server to be responsive during that period.
I have looked at various questions like

  1. Who should handle threading in MVC
  2. Can I use threads to carry out long running jobs on IIS
  3. How can long running thread work inside WEB application
  4. ASP.NET MVC Multithreading
  5. Run threads on server side show progress on client side possible

Question 4 also mentioned parallel namespaces, I think it might be my best option. I looked it up at MSDN. But I'm still confused whether to go for it or not.

If I use parallel namespace, would it work for 10^5 users using the server?

Community
  • 1
  • 1
Adze
  • 155
  • 1
  • 1
  • 12
  • "analyzing some data" - so it is CPU bound task? - no amount of parallelization will make more CPU resources available on server... IIS/ASP.Net in absolutely default configuration would run tens of requests in parallel using up all CPU in such case. – Alexei Levenkov Nov 10 '14 at 07:10
  • I would be analysing the Request user sends. – Adze Nov 10 '14 at 07:32

1 Answers1

1

It depends on what exactly you have there for "some data". If it is some extensive CPU processing then parallel processing would make it faster (but I don't think the server would be responsive during that period). If "some data" is about waiting for other resources to be available then I would go with asynchronous (async await).

Alex
  • 106
  • 4
  • I would be analysing the Request user sends, after that I need to insert the results into a database. – Adze Nov 10 '14 at 07:43
  • It sounds like asynchronous way is to follow. For example the insert into the database. If it takes most of the time, or it will in the future as database grows, then use asynchronous calls. [Here](http://msdn.microsoft.com/en-us/data/jj819165.aspx) is just an example how to save into database asynchronously using Entity Framework. – Alex Nov 10 '14 at 07:53
  • Note that answer about "extensive CPU processing then parallel processing would make it faster" assumes server gets single request at a time and way below 100% CPU usage. If you server need to handle more than one request at a time (i.e. as OP hinted in " 10^5 users using the server") adding parallel execution to CPU intensive tasks will likely make everything slower. – Alexei Levenkov Nov 10 '14 at 17:44