Lately I’ve heard a lot of discussion around the new.NET Core and its performance especially on web servers.
I didn’t want to start comparing two different things, so I did patience for quite long for a more stable version.
This Monday, Microsoft[announced the.NET Core version 2.0][7], so I feel ready to do it! Do you?
As we already mentioned, we will compare two identical things here, in terms of application, the expected response and the stability of their run times, so we will not try to put more things in the game like`JSON`or`XML`encoders and decoders, just a simple text message. To achieve a fair comparison we will use the[MVC architecture pattern][8]on both sides, Go and.NET Core.
### Prerequisites
[Go][9](or Golang): is a[rapidly growing][10]open source programming language designed for building simple, fast, and reliable software.
There are not lot of web frameworks for Go with MVC support but, luckily for us Iris does the job.
[Iris][11]: A fast, simple and efficient micro web framework for Go. It provides a beautifully expressive and easy to use foundation for your next website, API, or distributed app.
[C#][12]: is a general-purpose, object-oriented programming language. Its development team is led by[Anders Hejlsberg][13].
[.NET Core][14]: Develop high performance applications in less time, on any platform.
Download Go from[https://golang.org/dl][15]and.NET Core from[https://www.microsoft.com/net/core][16].
After you’ve download and install these, you will need Iris from Go’s side. Installation is very easy, just open your terminal and execute:
```
go get -u github.com/kataras/iris
```
### Benchmarking
#### Hardware
* Processor: Intel(R) Core(TM) i7–4710HQ CPU @ 2.50GHz 2.50GHz
* RAM: 8.00 GB
#### Software
* OS: Microsoft Windows [Version 10.0.15063], power plan is “High performance”
* HTTP Benchmark Tool:[https://github.com/codesenberg/bombardier][1], latest version 1.1
* .NET Core:[https://www.microsoft.com/net/core][2], latest version 2.0
* Iris:[https://github.com/kataras/iris][3], latest version 8.3 built with[go1.8.3][4]
Both of the applications will just return the text “value” on request path “api/values/{id}”.
For those who understand better by images, I did print my screen too!
Click[here][23]to see these screenshots.
#### Summary
* Time to complete the`5000000 requests`- smaller is better.
* Reqs/sec—bigger is better.
* Latency—smaller is better
* Throughput—bigger is better.
* Memory usage—smaller is better.
* LOC (Lines Of Code)—smaller is better.
.NET Core MVC Application, written using 86 lines of code, ran for2 minutes and 8 secondsserving39311.56requests per second within3.19mslatency in average and229.73ms max, the memory usage of all these was ~126MB (without the dotnet host).
Iris MVC Application, written using 27 lines of code, ran for47 secondsserving105643.71requests per second within1.18mslatency in average and22.01ms max, the memory usage of all these was ~12MB.
> There is also another benchmark with templates, scroll to the bottom.
Update 20 August 2017
As[Josh Clark][24]and[Scott Hanselman][25] pointed out on this[re-twee][26]t, on.NET Core`Startup.cs`file the line with`services.AddMvc();`can be replaced with`services.AddMvcCore();`. I followed their helpful instructions and re-run the benchmarks. The article now contains the latest benchmark output for the.NET Core application with the change both Josh and Scott noted.
@topdawgevh@shanselman they also used AddMvc() instead of AddMvcCore()... doesn't one include more middleware?
— @clarkis117
@clarkis117@topdawgevh Cool @MakisMaropoulos we'll take a look. @ben_a_adams@davidfowl. Good learnings on how to make easier performant defaults.
— @shanselman
@shanselman@clarkis117@topdawgevh@ben_a_adams@davidfowl@shanselman@ben_a_adams@davidfowl Thank you for your feedback! I did update the results, no difference. I'm open for any other suggestion
— @MakisMaropoulos
>It had a small difference but not as huge (8.91MB/s from 8.61MB/s)
For those who want to compare with the standard`services.AddMvc();`you can see the old output by pressing[here][27].
* * *
### Can you stay a bit longer for onemore?
Let’s run one more benchmark, spawn`1000000 requests`but this time we expect`HTML`generated by templates via the view engine.
* Time to complete the`1000000 requests`—smaller is better.
* Reqs/sec—bigger is better.
* Latency—smaller is better
* Memory usage—smaller is better.
* Throughput—bigger is better.
.NET Core MVC with Templates Application ran for1 minute and 20 secondsserving11738.60requests per second with89.03MB/swithin10.10mslatency in average and1.97smax, the memory usage of all these was ~193MB (without the dotnet host).
Iris MVC with Templates Application ran for37 secondsserving26656.76requests per second with192.51MB/swithin1.18mslatency in average and22.52msmax, the memory usage of all these was ~17MB.
### What next?
Download the example source code from[there][32]and run the same benchmarks from your machine, then come back here and share your results with the rest of us!
For those who want to add other go or c#.net core web frameworks to the list please push a PR to the`_benchmarks`folder inside[this repository][33].
I need to personally thanks the[dev.to][34]team for sharing my article at their twitter account, as well.
Go vs .NET Core in terms of HTTP performance { author: @MakisMaropoulos } https://t.co/IXL5LSpnjX
— @ThePracticalDev
Thank youall for the 100% green feedback, have fun!
#### Update: Monday, 21 August2017
A lot of people reached me saying that want to see a new benchmarking article based on the.NET Core’s lower levelKestrelthis time.
So I did, follow the below link to learn the performance difference between Kestrel and Iris, it contains a sessions storage management benchmark too!