I decided to do a quick benchmark of C# Webserver using ApacheBench. The 'WebserverExample' folder contains an index.htm which was used as output data, and 'HttpServerExample' was used as the server. The competitors are the
.Net 4 HttpListener class and the
Mono implementation of that same class.
1 concurrent connection, no keep-alives, 1000 requests:
C# Webserver: 43 req/sec
.Net HttpListener: 1968 req/sec
Mono HttpListener: 1712 req/sec
1 concurrent connection, keep-alive, 1000 requests:
C# Webserver: 87 req/sec
.Net HttpListener: 3194 req/sec
Mono HttpListener: 3007 req/sec
10 concurrent connections, 100.000 requests:
C# Webserver: 28 req/sec
.Net HttpListener: 4573 req/sec
Mono HttpListener: 6032 req/sec
The Mono code does exactly the same as C# Webserver (open socket, wait, etc.), so how can there be so much difference? The .Net class uses http.sys in kernelmode under the hood, so the comparison is not fair, but the Mono code is very similar?