I have a ASP.NET MVC project running on my developer machine with windows 7 ultimate and iis 7.5.
I do the following:
var requests = ["http://myserver.com/news/details/113834",
"http://myserver.com/tag/details?ids=113834&entityType=23",
"http://myserver.com/publish/details?ids=113834&entityType=23",
"http://myserver.com/generalproperty/details?ids=113834&entityType=23",
"http://myserver.com/category/details?ids=113834&entityType=23"];
var f = new Date().getTime();
$.each(requests, function(k,v) {
$.ajax({
url :v,
async : true,
type :'get',
success : function(data) {
console.log(new Date().getTime() -f );
}});
})
Then I get the following results(approx) 12, 521,1025,1550, 2067 async result http://martinhansen.no/hostedimages/async.PNG
If I switch the async to false I get : 14,32,49,58,68 sync result http://martinhansen.no/hostedimages/sync.PNG
Seems somewhere the requests are being queued up and after a while it responds only every 500 ish second. I have made my controllers return blank text instead of the database call, so not the database.
Is there a limitation on IIS 7.5 for windows 7? A setting I can change? I'm suspecting a max concurrent requests per user or something similar. And then it "punishes" you by responding every 500 ms only. So that people don't use it as an actual server.
Likely? And is there a way to avoid it?
It have nothing to do with IIS apperantly or IIS on windows 7, I also tried it on a test server and same results.
It was because of limitations imposed by sessionstate, see the "Concurrent Requests and Session State" section at the bottom here: http://msdn.microsoft.com/en-us/library/ms178581.aspx
However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished.
But I still don't understand why it don't fire off the next request right after the the first one is seemingly finished. It seems very fake the 500 ms delay.
I came over this question How to set the ASP.NET SessionState read-write LOCK time-out? that talks about the lock out time for the session state.
System.Web.SessionState.SessionStateModule.LOCKED_ITEM_POLLING_INTERVAL = 500
That's the magic number that I've been searching my code and the interwebs for.. 500! I knew it had to be somewhere.
Anyway, to fix this, I added the sessionstate attribute to my controllers with the option of read-only
[SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)]
public class BaseController : Controller{}
Read more about it:
http://afana.me/post/session-less-controllers-and-TempData-ASPNET-MVC.aspx
http://weblogs.asp.net/imranbaloch/archive/2010/07/10/concurrent-requests-in-asp-net-mvc.aspx
I still think something is wrong though, why don't the previous request tell the system that it no longer needs a lock on the sessionstate so that the next request can complete?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With