Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kestrel vs IIS+Kestrel performance (throughput) using .NET Core 2.2

For the .NET Core 2.2 application deployed on a single AWS EC2 host I am comparing IIS hosting vs plain Kestrel hosting.

For IIS configuration I followed MS documentation.

For Kestrel I simply used:

dotnet app.dll --server.urls http://*:5000

I am running "stress" test with JMeter in order to compare throughput. This test is simply calling app's endpoint with 100 threads for 10 seconds duration (5 seconds warmup). Note, that endpoint is basically getting same data from MSSQL Server database on each call, no caching etc.

As a result, Kestrel fails 75% of requests with socket closed/timeout errors:

enter image description here

QUESTION: What kind of configuration error can lead to such Kestrel behavior? I've tried to use a basic nginx reverse proxy in front of Kestrel, but still getting the same results.

like image 821
Sergey Nikitin Avatar asked Nov 07 '22 17:11

Sergey Nikitin


1 Answers

It turned out, that described behavior occurs when testing the performance of synchronous endpoint.

By following Thread injection algorithm, CLR will have only minWorkerThreads/minIoThreads to process requests and since "stress" test uses more threads than created at the moment we wait for new threads - which leads to almost linear growth of response time.

Switching to asynchronous eliminates the difference in performance, see: enter image description here

References:

  • ASP.NET MVC and Web API - Comparison of Async / Sync Actions
  • Official docs on CLR Thread Injection algorithm
  • Related SO issue
like image 109
Sergey Nikitin Avatar answered Nov 14 '22 21:11

Sergey Nikitin