Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web API Service - How to make the requests at the server to be executed concurrently

I am using a WebApi rest service controller, hosted by IIS 7.5, as i understood from this post:

Are all the web requests executed in parallel and handled asynchronously?

A webApi service, by default, executes all its incoming requests in parallel, but only if the current multiple requests (at a certain time) came from different sessions. That is to say, if single client will send some simultaneously requests to server, all of them will be executed sequentially and won't be executed concurrently.

This behavior is a real problem for us, because in some cases, our client sends bunch of requests from different client's listeners, asynchronously (by browser), and all of them will actually be queued instead of being executed concurrently at the server. Therefore, in some cases, we experiencing a serious performance issues which are really noticeable at the client's web page.

How can we solve this problem? I understand we can maybe disable session state but that isn't a normal thing to do.

like image 530
AmirTNinja Avatar asked May 25 '14 13:05

AmirTNinja


1 Answers

Actually, disabling session state is the normal solution for web APIs. If you need it for some/all of your calls, you can call HttpContext.SetSessionStateBehavior (e.g., from Application_BeginRequest). Multiple read-only session state requests can run concurrently.

like image 193
Stephen Cleary Avatar answered Oct 12 '22 13:10

Stephen Cleary