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?

2
  • "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. Commented Nov 10, 2014 at 7:10
  • I would be analysing the Request user sends. Commented Nov 10, 2014 at 7:32

1 Answer 1

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).

Sign up to request clarification or add additional context in comments.

3 Comments

I would be analysing the Request user sends, after that I need to insert the results into a database.
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 is just an example how to save into database asynchronously using Entity Framework.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.