I have an ASP.NET web app. On the client side, I've an Index.cshtml
page which currently gets populated with ~40 MB of IndexViewModel.cs
data on the GET
request.
On the server side, I have this action method to process the data:
public ActionResult Update(IndexViewModel modelData)
{
// validation
// submission of data to DB
return RedirectToAction(nameof(Index), modelData)
}
Structure of Index.cshtml
:
S#1: User inputs section
It consists of HTML input elements
and a Get Data button, which generates an Ajax call to get the data from db based on S#1
and populate the table in S#3
----------------------------------------------------------------------------------
S#2: A table with filtered data (filtered using jQuery) from table data in S#3
this table's data is editable
----------------------------------------------------------------------------------
S#3: A table that gets populated currently with somewhat closer to ~18000 records from DB on
click of the Get Data button in S#1, and this is not editable
----------------------------------------------------------------------------------
IndexViewModel.cs
:
public class IndexViewModel
{
List<TableSelector> tableSelectors { get; set; }
List<SourceTable> srcTbl { get; set; }
List<DestinationTable> destinationTbl { get; set; }
}
While submitting the form data both srcTbl
and destinationTbl
consists of ~18000 records each.
The server is hosted as an Azure web app service. The timeout on the Azure app gateway is set to 3 minutes.
When debugging from the local machine, the process takes time but it executes as expected and everything works as it should. But in Azure, after 3 minutes, I get a response:
504 Gateway timed out
But when checking the db, after around 5 minutes, I can see that the submitted data is available and the db has been updated.
Therefore, I tried increasing the timeout limit to 5 minutes and then submitting the form data. But, after 4 minutes, I get a 500 Internal Server error
. The data size will keep increasing so increasing the timeout on the Azure app gateway is not the solution. But I also need the whole model at once to work within the body of Update()
.
I measured different times from local machine, like:
- How much time is it taking for the request to reach the first line inside the body of the
Update()
?
Around 5-7 minutes - How much time is it taking to process the data inside the body of
Update()
?
Less than 30 seconds
According to these results, I came to the conclusion that most of the time is getting consumed by ASP.NET to prepare that IndexViewModel modelData
parameter from the request body. Therefore, my question is how should I submit the data from the client to the server so that I get the whole model and also I get it efficiently and respond with a valid response within the 3 minutes timeout limit?
Note: this whole submitted code is of a similar sample app to the original one since I do not have the rights to the original code to use/submit/publish it elsewhere. The original app runs on .NET Framework v4.7 and the sample app runs on .NET 7. However, these versions shouldn't affect my question, because my question is of logic, is for an efficient approach.