Why do we get this error "Reading the request body timed out due to data arriving too slowly. See MinRequestBodyDataRate." if we have not configured MinRequestBodyDataRate??

Abhay B Abraham 0 Reputation points
2023-06-15T06:38:03+00:00

Our system utilizes ASP.NET Core 6.0.10 and HTTP/2. There is no specific configuration for the MinRequestBodyDataRate in our program, indicating that it likely uses the default value of 240 bytes per second. During our investigation, we have confirmed that when this error arises, there are no discernible variations in any of the metrics, including RequestCount, CPU usage, and Memory usage. Our system is hosted on AKS.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,596 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,502 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,141 questions
Azure ISV (Independent Software Vendors) and Startups
Azure ISV (Independent Software Vendors) and Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.ISV (Independent Software Vendors) and Startups: A Microsoft program that helps customers adopt Microsoft Cloud solutions and drive user adoption.
97 questions
{count} votes

1 answer

Sort by: Most helpful
  1. navba-MSFT 24,890 Reputation points Microsoft Employee
    2023-06-16T04:55:07.5033333+00:00

    @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:

    1. 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.
    2. Having the clients / client app in same region as that of AKS would eliminate such client side network latencies.
    3. 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
    4. This will help in checking if the Request Body is too large.
    5. 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
    6. 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.