Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

High Performance ASP.NET Site (> 1000 Request/Second)

I am writing a High Performance ASP.NET Json API with soon > 1000 Request/Second. All my logic and processing is done in an IHttpHandler. I measured via Stopwatch Class and the handler finishes a request in around 0,1 - 0,5 Millisecond.

But it seems IIS and/or other HTTPHandlers (Modules?) are taking away a lot of performance. Can i measure that somehow ? How much overhead will a request produce in IIS when configured for best performance ?

Will removing all those HTTPHandlers help, or are there other tricks to speed it up? I dont need much of the ASP.NET Featureset besides Session (could even workaround that if it give a significant performance boost).

like image 999
TobiHeidi Avatar asked Mar 20 '12 22:03

TobiHeidi


People also ask

How many requests per second can asp net core handle?

ASP.NET Core – Exceeds 1.15 Million request/s, 12.6 Gbps NET Core teams and the Open Source . NET community for quite a milestone in performance!

How does ASP.NET handle multiple requests?

The gist of it is that a number (probly less than 1000) threads handle a number of request simultaneously, and the rest of the requests get queued. When the queue gets full, the web server starts rejecting requests.

How does ASP.NET handle concurrent requests?

The answer is that when ASP.NET see two or more requests from the same user( by checking their SessionID) and session is marked with both Read and Write, then it will execute the first request and queue all other requests such that only one request will execute from the same user at the same time.


1 Answers

Measuring performance of a web server is no trivial task. A few things to consider:

  • Find the actual bottleneck. This can be memory, disk access, caching, database access, network latency etc. Use a memory profiler, or other performance profiler to find out.
  • Use WireShark to find the difference between how long the request is on your machine and how long your code runs.
  • Try other configurations. Give ASP.NET more memory. Upgrade the test system. I.e., going from 8GB / 2.5GHz with 600 requests/sec to 16GB / 3.0GHz can yield 6500 requests/sec. Performance growth is often not linear. See this document from Microsoft.
  • Consider adding an extra machine. This can yield up to a 50 or even higher performance upgrade depending on how you configure it. See again that document from MS.
  • Check these hints by Jon Skeet. The comment thread reveals some non-obvious potential bottlenecks as well.

NOTE 1: know your tools. ASP.NET runs each request in its own thread. Thread swapping is faster than process swapping, but it still requires time. If other handlers take time because they are in the request chain, it's beneficial to disable them.

NOTE 2: one of the original side-goals of stackoverflow was to create a site in ASP.NET that had great performance on max 2 servers and could handle > 1Mln visitors per hour. They managed to do that. I believe they wrote some blogposts on it, but I don't remember where they are.

like image 116
Abel Avatar answered Oct 21 '22 10:10

Abel