NancyFx vs. FeatherHttp
As a long time fan of the lightweight syntax of the awesome NancyFx web framework, I was really curious when I stumbled upon FeatherHttp, a new low-ceremony framework for building web services in .Net Core applications.
Naturally, I was curious not only about the syntax but about the performance as well. So I decided to compare their raw performance, using the awesome wrk2 tool.
As a first step, I created two HTTP servers with one endpoint that does the same work in both cases.
NancyFx server code looks like this:
1 | public class HelloWorldModule : NancyModule |
And FeatherHttp server code looks like this:
1 | class Program |
I really LOVED the syntax of FeatherHttp - really concise and low-ceremonly. It is even shorter than NancyFx!
The next step was to actually do the benchmarking. I ran the following command for both of the services, which were compiled using .Net Core 3.1
1 | wrk -c500 -t4 -d30s -R2000 http://localhost:5000/ |
Those parameters mean - open 500 connections, try to maintain 2000 req/sec over 30 seconds and use 4 threads for concurrent requests
For NancyFx I got:
1 | Running 30s test @ http://localhost:5000/ |
And for FeatherHttp I got:
1 | Running 30s test @ http://localhost:5000/ |
The numbers mean that FeatherHttp is a winner by only a small margin. Though, during high workloads, 10% improvement in throughput could be significant.
Note that this is a very basic comparison of performance capabilities of both frameworks. First, despite it’s relatively complete API, FeatherHttp is at an alpha stage, so its performance might change in the future, for better or for worse.
Second, and more importantly, a true performance benchmark would involve comparing the speed of routing algorithm, memory allocations per request and per use of various features and more.
Overall, I am excited by FeatherHttp framework and intend to use it in one of my pet projects as soon as opportunity arises :)