0
votes

I think this is a recurring question but I couldn't find an specific answer to my doubt.

I have a Asp.net MVC3 application, we are going to switch to AsyncController to improve the app and I think all the setup is done right. However, this app will run in load balancer with one central session state server. Asp.net State Service.

The request to need to read from session, so with hundreds parallel requests from many users will requests end up queuing up due to session object serialization back and forth to the state server? Or worst will I end up with session object NULL if my Task.StartNew() thread takes a while to complete? And that multiplied by many users ...

I guess forget writing to session on these requests right? Would it give error or just ignore the written value?

Let's suppose thread pool size is not in the equation, I'd like to understand how session (wait) behaves in this scenario.

EDIT Can you explain why this works and is it granted in all stress scenarios?

var current = System.Web.HttpContext.Current;

            AsyncManager.OutstandingOperations.Increment();
            Task.Factory.StartNew(() =>
            {
                System.Web.HttpContext.Current = current;

Thanks

1
Are you actually experiencing a performance problem with the state server/session?Erik Philips
Not yet, I'm trying to research what concerns I should have, if any, before spending weeks of development to see it failing stress test. Of course that can't be 100% ensured.user4709865

1 Answers

1
votes

Storing session state in State Server should not affect on async await, and vice versa.

Problem

We should not use HttpContext (session state in your case) inside Task.Run(something). Due to the nature of the web request, HttpContext might not be available inside the spawned thread.

FYI: I do not see you mention about Cache in your question while using load balancing. You will need to take into considerations if the application happens to use Cache.