BadHttpRequest and Bad Performance from simple .NET Core Web API - what am I missing?

Mike Koleno 1 Reputation point
2021-08-02T00:12:44.263+00:00

I am running a fairly standard .NET Core Web API running in Google App Engine and while my API controllers are naturally asynchronous, my business layer runs synchronously. I am using EF with a MySQL database and anytime my API takes on more than 10+ requests at once, I start to see this exception everywhere and my API performance grinds to a halt.

I have a beefing PaaS configurations with elasticity enabled for both of my App Engine and Cloud SQL configurations. I know I could save some performance by turning my business tier into async calls but should my API be grinding to halt with such low volume? What else could I be doing wrong?

Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException:
Unexpected end of request content

The above is the exception that is generated over and over again. I am again wondering what this information might tell me...?

Thanks in advance!

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,226 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,354 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Valentin Peta 1 Reputation point
    2022-04-08T15:45:46.327+00:00

    In our case tweaking the thread pool seems to have solved the issue:

    ThreadPool.SetMaxThreads(32_767, 2_000);
    ThreadPool.SetMinThreads(1_000, 1_000);

    0 comments No comments

  2. Bruce (SqlWork.com) 57,641 Reputation points
    2022-08-26T14:55:43.29+00:00

    Asp.net core does not scale well with long running sync code. There is only one process thread per cpu, and it looks like you are using them up.

    Your actions can run the sync code with Task.Run() and become async. This will allow the process threads to do more work.

    0 comments No comments