@Abhay B Abraham Apologies for the late reply. Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I understand that you are encountering the error Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate
for your ASP.NET core application hosted on AKS.
From the error message, it is pretty clear that the ASP.NET Core HTTP pipeline is timing out while waiting for the request body to be received. I see that you haven't configured the MinRequestBodyDataRate
in your application. In that case the default value of 240 bytes per second will be used. See here.
If the request body is being received at a rate slower than this, the HTTP pipeline will time out. You could try to increase this value to a higher value and check if that helps to address this.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.Configure<RequestBodyOptions>(options =>
{
options.MinRequestBodyDataRate = 1024; // 1 kilobyte per second
});
}
}
OR***
.UseKestrel(options =>
{
options.Limits.MinRequestBodyDataRate =
new MinDataRate(bytesPerSecond: 1024, gracePeriod: TimeSpan.FromSeconds(10));
});
The above code snippet will tell the Asp.Net core HTTP pipeline to wait for up to 1 kilobyte of data per second before timing out.
If you are still experiencing timeouts, you can try increasing the value of the MinRequestBodyDataRate
setting further. However, it is important to note that if you set this to a very HIGH value it might lead to high memory performance issues.
If you want to identify the root cause of the issue, you can follow the below pointers:
- The client (end user / client application) which is calling your asp.net core AKS app seems to be sending data in very slow rate. Slow data arrival can be caused by network latency between the client and your AKS cluster. Check if there are any network issues or congestion on the client side that could be impacting the data transfer speed.
- Having the clients / client app in same region as that of AKS would eliminate such client side network latencies.
- I understand that you have already confirmed that memory and CPU usage etc are normal, Could you please check the Network_In_Bytes AKS metrics at the node and pool level to observe the Average Bytes read: https://video2.skills-academy.com/en-us/azure/azure-monitor/essentials/metrics-supported#:~:text=node_network_in_bytes
- This will help in checking if the Request Body is too large.
- Additionally, monitoring your application's performance metrics, such as request duration, network latency, and resource utilization, can provide valuable insights during the troubleshooting process. Application Insights provides complete monitoring of applications running on AKS and other environments. Refer this for asp.net core logging: https://video2.skills-academy.com/en-us/azure/azure-monitor/app/asp-net-core
- Refer this article for some best practices while reading large request bodies. https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/blob/master/AspNetCoreGuidance.md#table-of-contents
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.