Quick Background: I understand that HTTPListener uses http.sys kernel driver which supposedly makes it a great performer. However, when doing some performance benchmarks between a managed http server and a native vc++ server I am seeing approx 15 MB/s increase on the native side. Test setup is two lab machines freshly formatted with 1gb nics. On the native side I am seeing about 110 MB/s which is close to 100% of the nic minus overhead, when using HTTPListener I am seeing ~94 MB/s (max 100).
The tests are apples to apples,
Overall I expect that I should be able to get close to the 110 MB/s of the native server via HTTPListener, 15 MB/s seems pretty costly.
Questions: 1. Are there other optimizations for managed that I am missing? 2. What are some potential bottlenecks, I looked at the HTTPResponseStream via reflector, looks like there is some marshaling going on, but no glaring issues, In fact when using chunking it produces an identical chunk array as my native server.
Any ideas are appreciated,
The fact that it uses Http.sys doesn't mean that there isn't a native-to-managed transition. From the above-mentioned MSDN article:
HTTP.sys provides connection management, bandwidth throttling, and Web server logging.
By virtue of the fact that you are running managed code, you have interop (native to managed, not to be confused with COM interop), you have garbage collection, etc. It's never going to be as fast as a pure native c++ implementation.
EDIT: To make this clearer, you are still running a .NET process, you are just hooking into IIS in kernel mode, not in user mode. A great article on this is here: http://www.west-wind.com/presentations/howaspnetworks/howaspnetworks.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With