Rob Bowman
Rob Bowman

Reputation: 8751

Http Post - long delay at state ExecuteRequestHandler

I have an asp.net mvc website hosted on Windows Server 2012r2 Standard which uses KnockoutJS to display data in a grid. This server is dedicated to the process that I'm having trouble with - it does not server any other requests.

An ajax call is made to a "GetRecords" action of a controller. This returns data for a couple of dozen records very quickly.

The user is able to make amendments to the data and submit for update. The knockout code makes another ajax call, this time posting the records. At this point the site "hangs" for a long time (over 10 minutes), but it does complete successfully and the updated date is persisted to a database. During the "hang time" the CPU for the IIS Worker Processes hovers around the 50% mark.

I'm trying to figure out what's causing the delay. It seems that the delay happens before the first line of code of the controller action is reached. I've added trace statements to the action and I can see that once the 1st line is executed, then the action completes within a couple of seconds.

From the IIS manager, I've drilled in to "Worker Processes"\"Current Requests" during the time the page is "hung", I can see that the State is listed as "ExecuteRequestHandler" and the Module Name is "ManagedPipelineHandler". There are no other "Current Requests" displayed.

Using the Chrome dev tools, I've captured the json being posted for the update, it is approx 4mb in size.

I've ruled out the problem being caused by bandwidth because I've tested from a browser running locally (on the web server), and I get the same delay.

Also, when I post the same number of records on the same site hosted on my dev VM then it works fine - completes end-to-end in under 3 seconds.

Any suggestion on steps I can take to improve performance of the post?

I have created a process dump of the IIS worker process when it is in the "hanging" state, this is available at: onedrive link

It seems that "Thread 28" is causing the issue, since this has a "Time spent in user mode" value of over 2 minutes. I requested the process dump about 2 minutes after making the http post request from the website. The post did eventually complete ok after about 20 minutes

Upvotes: 0

Views: 3720

Answers (1)

Rob Bowman
Rob Bowman

Reputation: 8751

Able to work around this problem bypassing the MVC model binding. The view model param (editBatchVm) that was passed into the controller method has been replaced. So, instead of:

public void ResubmitRejectedVouchersAsNewBatch(EditBatchViewModel editBatchVm)
    {

I now have:

public void ResubmitRejectedVouchersAsNewBatch()
{
    string requestData = "";
    using (var reader = new StreamReader(Request.InputStream))
    {
        requestData = reader.ReadToEnd();
    }
    EditBatchViewModel editBatchVm = JsonConvert.DeserializeObject<EditBatchViewModel>(requestData);

Upvotes: 1

Related Questions