question

MikeKoleno-5714 avatar image
0 Votes"
MikeKoleno-5714 asked ValentinPeta-8579 answered

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

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!

dotnet-csharpdotnet-aspnet-core-webapi
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

This is a 400 and it says Unexpected end of request content. I would say it's something wrong with the request payload, and not a performance issue

0 Votes 0 ·

Hi Mike,
Did you find out where the issue was? I am also observing this behavior in .NET 5.
Thanks,
Valentin

0 Votes 0 ·

1 Answer

ValentinPeta-8579 avatar image
0 Votes"
ValentinPeta-8579 answered

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);

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.