IIS requests queued after page hangs - c#

When a page is taking a long time to process in IIS, all other page requests coming in are delayed until the first one either times out, or responds.
This was brought to light by a 3rd party API having high response times. However, I can duplicate the issue by putting a Sleep in any page.
We are using DNN version 7.0.6
For Example:
The page http://www.website.com/foo.aspx has the code System.Threading.Thread.Sleep(10000); in the Page_Load.
While this page is sleeping, http://www.website.com/bar.aspx is requested. Bar.aspx (a page that usually responds right away) will not respond until foo.aspx has completed it's request.
From IIS Logs, you can see this process:
#Fields: date time cs-uri-stem sc-status sc-substatus sc-win32-status time-taken
2016-08-24 19:44:20 /bar.aspx 200 0 0 69
2016-08-24 19:44:24 /foo.aspx 200 0 0 10053
2016-08-24 19:44:24 /bar.aspx 200 0 0 9204
2016-08-24 19:44:26 /bar.aspx 200 0 0 91
I have tried adding additional worker processes, and the problem still exists.
I feel like I'm missing something simple. Am I just overlooking some fundamental way IIS or DNN works? Can anything be done to prevent this from happening?

Related

Load testing in Visual Studio. How number of simultaneous users is implemented in Visual Studio?

Could you please explain, how load or stress test is released inside Visual Studio when the test is oriented on the number of simultaneous users?
Example:
Step user count: 0
Initial user count: 2.
Run duration and step duration: does not important really because user count is always the same (2), let it be 30 seconds for run duration and 30 seconds for step duration. It is a kind bit weird configuration for the test but it helps to show the main idea of my question.
Web serivce is able to response after small period of time (0.1-0.5 sec).
There are 2 users in load test, they start request to web-service, one user recieved request result and one did not recieve. When the first user will start another request, 1) immediately after recieving his response, 2) or when the second user will recieve response too? Am I right that users' requests start absolutely idependently, one user is able to recieve 30/0.1=300 responses and the second one is able to recieve 30/0.5=60 responses after the test? Users send the same requests to the same service.
In these 2 scenarious could be different number of errors that will be recieved during this small test. For me, it is important to understand after what period of time (or event) the next request will begin for the same user?
Thank you.

IIS 8.5 connection timeout is _always_ 60 seconds

I have an ASP.NET application running on IIS 8.5 that times out at 60 seconds regardless of what I set. In other words, I can set the connection timeout to 300 seconds or 30 seconds and the page will still time out at 60 seconds. The Request status code is 504 GATEWAY_TIMEOUT.
Site:
Connection timeout = 300 seconds (5 mins)
Session timeout = 20 minutes
Script timeout = 10 minutes
App Pool:
.NET CLR v4.0
Integrated pipeline
64-bit (32-bit not allowed)
Idle timeout = 20 mins (default)
Other things I've done:
Read just about every article I can on this subject
Set the executionTimeout in my web.config
Restarted the site or ran iisreset after each change
Disabled all sites except this one to isolate it
Created a simple ASPX page in which I set a Sleep thread to under or over 60 seconds, and tried every combination with the connection timeout value.
I'm at a loss. Any ideas?
The answer turned out to be a load balancer, which I was unaware existed, that had its own timeout setting.
Check your maxRequestLength, apparently that can cause a 504 if the incoming request exceeds the default limit of 4MB.
504 Error On Server
Can big ViewState content result a HTTP Error 504 - Gateway timeout?

App to app authentication with Windows Authentication taking 10 seconds

We are doing http calls with Windows Authentication between asp.net apps (specifically a .net core an and a standard .net framework 4.5.1 app) apps using System.Net.Http.HttpClient like this:
var client = new HttpClient(new HttpClientHandler { Credentials = CredentialCache.DefaultCredentials });
var response= await _winHttpClient.GetAsync(url);
...
This works fine, except for that the first request takes 10 seconds. The requests then go fast for about 40 seconds, and then one request takes 10 seconds. This cycle goes on forever.
Looking at the IIS logs on the receiving end, we can se that every request is denied (401) and then a follow up request goes through, and every so often the delay between these are about 10s. This is all invisible to the client code - it is worked out by the underlying framework.
Example:
2017-03-17 14:19:40 10.241.108.23 GET /person/search/john - 80 - 10.211.37.246 - 401 2 5 31
2017-03-17 14:19:40 10.241.108.23 GET /person/search/john - 80 utv\frank 10.211.37.246 - 200 0 0 93
2017-03-17 14:19:41 10.241.108.23 GET /person/search/johnn - 80 - 10.211.37.246 - 401 2 5 46
2017-03-17 14:19:51 10.241.108.23 GET /person/search/johnn - 80 utv\frank 10.211.37.246 - 200 0 0 281
It seems as if the credentials are somehow cached, and have to be refreshed every 40ish seconds.
It is worth noting that this problem doesn't occur when both applications are run locally, only when they are run in the actual hosting environment.
What's going on?
Is it expected behaviour that the consumer has to do two calls for every request? And why do some of the requests take 10 seconds to authenticate?
Any help would be appreciated.

When executionTimeout is reached, what happens?

If the default is 110 seconds why do I see requests going beyond that (up to 177 seconds)?
I'd expect and hope that once time is reached the request is cancelled and resources reallocated.
I'm seeing these response times in my apm tool (dynatrace) which instruments the code and doesn't likely get the time from the server logs
( referring to In our IIS logs, why do requests last 5 min and longer when executionTimeout is 110 seconds?)
Thank you
Have you considered the requests may be being queued on the server? If you look at perfmon RequestsQueued you might see some queuing going on.
Also look at request wait time to get an indication of how long the last request waited.
Can you send a screenshot of the PurePath showing the Exec Time but also the Elapsed Time column in the tree? Maybe the PurePath itself actually gets aborted by IIS after 110 s but some asynchronous activity in your ASP.NET App is still working and was not interrupted by the IIS Timeout. The PurePath tree should show that as it shows asynchronous subpaths
andi

Huge delays for some requests in an ASP.NET MVC project

I have a problem with an ASP.NET MVC project hosted on IIS. I'm flooding the same request hundreds of times:
function Test(count){
for(var i=0; i<count; i++){
$.ajax({
url: "http://example.com?someparam=sth&test="+i,
context: document.body
}).done(function() {
console.log("done");
});
}
}
Test(500)
Here is the taken time of each request in milliseconds (here are just a part of the sent requests):
221
215
225
429
217
228
227
209
236
355
213
224
257
249
223
211
227
1227
168
181
257
3241
201
244
130
198
283
1714
146
136
177
3304
294
868
772
2750
138
1283
221
775
136
235
792
278
641
1707
880
1711
As you can see there are peaks for some of the requests and the taken time could be more than 10 times of the average of the other requests.
I though it could be a Garbage Collector issue, but I think it's not. I called GB on each request. I had the same result, the delays were still there in the log.
This happens not only for my MVC project but either for an empty MVC project.
I created a new MVC project and sent lots of requests to Home/About. The result was same.
I tried with an action that returns EmprtActionResult... same result.
If anybody knows why this happens and has a solution for the problem or just has a suggestion ... please share the information, I will be really grateful
Also I'm using .NET Memory Profiler, but I can't find out how to track each request and catch exactly the requests with delays. Can I do it with .NET Memory Profiler? If I don't please suggest another profiler that will be working for me.
Thank you!
EDIT: I also tried with an empty WebForms project. There were delays just for the firs 5 requests ... but this is because of IIS warming up for sure. And no delays for the next 1495 requests.
Your testing methodology has no way to identify where your bottleneck might be occurring, only that something is causing your delay.
Also, there is no mention whether this is an isolated server. If you are hitting a production website, you'll be affected when pages are requested by visitors accessing the web site.
At the very least, you'll need to add a control to this. I would start by loading a plain text file from the same web server. Another point to note is that most web browsers will limit the number of concurrent requests to the same web site. Usually, that is two simultaneous requests. Your delay could be a backlog of ajax requests in your client.

Categories

Resources