Go vs .NET Core 2.1
.NET Core 2.1 正式发布之际,微软团队在博客的中提到了 .NET Core 2.1 中的性能提升。这让我想起了去年 Go 语言 Iris MVC 框架作者做的 Go 与 .NET Core 2.0 之间的性能对比(具体可看https://hackernoon.com/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8 ),当时的 Iris 在各个方面的表现都基本超出 .NET Core 至少 1 倍,测试结果在社区中引发了不小的讨论,事后,微软团队的成员与 Iris 的作者进行了亲切友好的会谈,并就 Web 框架性能调优相关方面展开了深入的讨论。现在 .NET Core 2.1 版本正式发布,让我们来看看现在的 .NET Core 性能到底如何。
跑分仅供参考
测试项目地址:https://github.com/zeekozhu/iris
原文地址:https://hackernoon.com/go-vs-net-core-in-terms-of-http-performance-7535a61b67b8
硬件配置
处理器: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz 2.50GHz
内存容量: 16.00 GB
软件版本
OS: Microsoft Windows [版本号 10 1803 17134.48], 电源计划:“最佳性能”
HTTP 跑分工具: https://github.com/codesenberg/bombardier, 最新版本 1.1
.NET Core SDK: https://www.microsoft.com/net/core, 最新版本 2.1.300
Iris: https://github.com/kataras/iris, 最新版本 10.6.5 使用 go1.10.2-windows/amd64 编译
本次测试分三轮进行。第一轮测试中,服务器只返回简单的纯文本。第二轮测试中,服务器需要响应渲染出来的 HTML 模板。第三轮测试中,服务器都使用低层 API 来处理请求,并响应简单的纯文本。
响应简单文本内容
为了避免特定格式(如,JSON
,XML
)序列化以及编码带来的影响,所以这次测试中仅测试了对简单文本的响应速度与稳定性。为了公平起见,Go 与 .NET Core 都使用了日常开发中最常用的 MVC 模式。
.NET Core MVC
$ cd netcore-mvc
$ dotnet run -c Release
Hosting environment: Production
Content root path: C:\mygopath\src\github.com\kataras\iris\_benchmarks\netcore-mvc
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
Application is shutting down...
$ bombardier -c 125 -n 5000000 http://localhost:5000/api/values/5
Bombarding http://localhost:5000/api/values/5 with 5000000 request(s) using 125 connection(s)5000000 / 5000000 [================================================================================] 100.00% 2m16s
Done!
Statistics Avg Stdev MaxReqs/sec 36682.65 7344.86 125924.45Latency 3.40ms 449.42us 254.50msHTTP codes:1xx - 0, 2xx - 5000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 8.09MB/s
Iris MVC
$ cd iris-mvc
$ go run main.go
Now listening on: http://localhost:5000
Application started. Press CTRL+C to shut down.
$ bombardier -c 125 -n 5000000 http://localhost:5000/api/values/5
Bombarding http://localhost:5000/api/values/5 with 5000000 request(s) using 125 connection(s)5000000 / 5000000 [================================================================================] 100.00% 1m11s
Done!
Statistics Avg Stdev MaxReqs/sec 70416.19 10167.84 89850.59Latency 1.77ms 74.69us 31.50msHTTP codes:1xx - 0, 2xx - 5000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 13.09MB/s
简单文本性能测试结果
完成
5000000 请求
的时间 - 越小越好。Reqs/sec - 越大越好。
Latency - 越小越好。
Throughput - 越大越好。
.NET Core MVC 程序,使用了 2 分 16 秒完成了测试,平均每秒能够处理:36682.65 个请求,平均的响应延迟在 3.40ms 左右,最大延迟为 254.50ms。
Iris MVC 程序,使用了 1 分 11 秒完成了测试,平均每秒能够处理:70416.19 个请求,平均的响应延迟在 1.77ms 左右,最大延迟为 31.50ms。
MVC + Templates
接下来就是 MVC 服务端模板渲染性能测试,在这个测试中,服务端程序一共需要处理 1000000 个请求,并响应通过视图引擎渲染出来的 HTML。
.NET Core MVC with Templates
$ cd netcore-mvc-templates
$ dotnet run -c Release
Hosting environment: Production
Content root path: C:\mygopath\src\github.com\kataras\iris\_benchmarks\netcore-mvc-templates
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
Application is shutting down...
$ bombardier -c 125 -n 1000000 http://localhost:5000
Bombarding http://localhost:5000 with 1000000 request(s) using 125 connection(s)1000000 / 1000000 [=================================================================================] 100.00% 1m18s
Done!
Statistics Avg Stdev MaxReqs/sec 13043.07 4754.11 120734.38Latency 9.74ms 2.07ms 464.00msHTTP codes:1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 92.25MB/s
Iris MVC with Templates
$ cd iris-mvc-templates
$ go run main.go
Now listening on: http://localhost:5000
Application started. Press CTRL+C to shut down.
$ bombardier -c 125 -n 1000000 http://localhost:5000
Bombarding http://localhost:5000 with 1000000 request(s) using 125 connection(s)1000000 / 1000000 [==================================================================================] 100.00% 37s
Done!
Statistics Avg Stdev MaxReqs/sec 26927.88 4174.31 33129.39Latency 4.64ms 206.76us 34.00msHTTP codes:1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 194.24MB/s
视图性能测试结果
完成
1000000 请求
的时间 - 越小越好。Reqs/sec - 越大越好。
Latency - 越小越好。
Throughput - 越大越好。
.NET Core MVC 程序,使用了 1 分 18 秒完成了测试,平均每秒能够处理:13043.07 个请求,平均的响应延迟在 9.74ms 左右,最大延迟为 464.00ms。
Iris MVC 程序,使用了 37 秒完成了测试,平均每秒能够处理:33129.39 个请求,平均的响应延迟在 4.64ms 左右,最大延迟为 34.00ms。
低层 API 简单文本性能测试
在本次测试中,服务端程序需要处理 1000000 个请求,并返回一个简单的纯文本响应。.NET Core 不再使用 ASP.NET Core MVC,而是直接通过 Kestrel 处理请求,Iris 也会使用底层的 Handlers 来处理请求。
.NET Core (Kestrel)
$ cd netcore
$ dotnet run -c Release
Hosting environment: Production
Content root path: C:\mygopath\src\github.com\kataras\iris\_benchmarks\netcore
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
$ bombardier -c 125 -n 1000000 http://localhost:5000/api/values/5
Bombarding http://localhost:5000/api/values/5 with 1000000 request(s) using 125 connection(s)1000000 / 1000000 [==================================================================================] 100.00% 17s
Done!
Statistics Avg Stdev MaxReqs/sec 55937.72 4492.32 66770.94Latency 2.23ms 328.65us 87.00msHTTP codes:1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 10.13MB/s
Iris
$ cd iris
$ go run main.go
Now listening on: http://localhost:5000
Application started. Press CTRL+C to shut down.
$ bombardier -c 125 -n 1000000 http://localhost:5000/api/values/5
Bombarding http://localhost:5000/api/values/5 with 1000000 request(s) using 125 connection(s)1000000 / 1000000 [==================================================================================] 100.00% 12s
Done!
Statistics Avg Stdev MaxReqs/sec 80559.83 6029.77 92301.38Latency 1.55ms 185.02us 34.50msHTTP codes:1xx - 0, 2xx - 1000000, 3xx - 0, 4xx - 0, 5xx - 0others - 0Throughput: 14.98MB/s
低层 API 简单文本性能测试结果
完成
1000000 请求
的时间 - 越小越好。Reqs/sec - 越大越好。
Latency - 越小越好。
Throughput - 越大越好。
.NET Core MVC 程序,使用了 17 秒完成了测试,平均每秒能够处理:55937.72 个请求,平均的响应延迟在 2.23ms 左右,最大延迟为 87.00ms。
Iris MVC 程序,使用了 12 秒完成了测试,平均每秒能够处理:80559.83 个请求,平均的响应延迟在 1.55ms 左右,最大延迟为 34.50ms。
总结
尽管微软在发行说明中提到了 .NET Core 2.1 有较大幅度的性能提升,但是在我的测试结果中与去年 Iris 作者运行的测试结果相差并不是很大。如果你认为本文的测试代码有问题,欢迎在评论区指出。
原文地址:https://www.cnblogs.com/JacZhu/p/9120817.html
.NET社区新闻,深度好文,欢迎访问公众号文章汇总 http://www.csharpkit.com
Go vs .NET Core 2.1相关推荐
- H.265 HD 和H.265 4K Video Encoder IP Core
H.265 HD 和H.265 4K Video Encoder IP Core H.265 HD Video Encoder IP Core(H.265 HD Video/Audio Encoder ...
- NVIDIA深度学习Tensor Core性能解析(下)
NVIDIA深度学习Tensor Core性能解析(下) DeepBench推理测试之RNN和Sparse GEMM DeepBench的最后一项推理测试是RNN和Sparse GEMM,虽然测试中可 ...
- NVIDIA深度学习Tensor Core性能解析(上)
NVIDIA深度学习Tensor Core性能解析(上) 本篇将通过多项测试来考验Volta架构,利用各种深度学习框架来了解Tensor Core的性能. 很多时候,深度学习这样的新领域会让人难以理解 ...
- Tensor Core技术解析(上)
Tensor Core技术解析(上) NVIDIA在SIGGRAPH 2018上正式发布了新一代GPU架构--Turing(图灵),黄仁勋称Turing架构是自2006年CUDA GPU发明以来最大的 ...
- 2021年大数据Spark(十八):Spark Core的RDD Checkpoint
目录 RDD Checkpoint 引入 API 代码演示 总结:持久化和Checkpoint的区别 问题: 答案: 区别: RDD Checkpoint 引入 RDD 数据可以持久化,但是持久化/缓 ...
- .NET Core微服务之基于MassTransit实现数据最终一致性(Part 1)
Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.预备知识:数据一致性 关于数据一致性的文章,园子里已经有很多了,如果你还不了解,那么可以通过以下的几篇文章去快速地了解了解,有个感性认 ...
- Asp.Net Core在线生成二维码
前言: 原先用zxing Code写过基于Winfrom的批量生成二维码工具,以及单个生成二维码工具:批量生成二维码Gihub源代码 今天尝试用QRCoder 加 Asp.Net Core 写了一个在 ...
- .Net Core快速创建Windows服务
1.新建.Net Core控制台程序,添加新建项Windows服务: 修改Progran.cs: class Program{static void Main(string[] args){Servi ...
- .net core 中的[FromBody]
一.针对.net core中post类型的api注意的地方(前提是Controller上加[ApiController]特性).默认是这个. 1.如果客户端Content-Type是applicati ...
- PetaPoco - 轻量级高性能的ORM框架(支持.NET Core)
我们都知道ORM全称叫做Object Relationship Mapper,也就是可以用object来map我们的db. 而且市面上的orm框架有很多,有重量级的Entity Framework,有 ...
最新文章
- 详解OpenCV卷积滤波之边缘处理与锚定输出
- c语言编程功率谱,有谁会用C编写求功率谱(答案越多越好)
- Java连接数据库(2)
- 概述nodejs核心机制
- php代码文字中怎么换行符,如何在imagestring(php中的文本到图像)中添加换行符(br)...
- 求数字序列中的第n位对应的数字
- 完全卸载HDP和Ambari
- Qt应用程序只运行一个实例
- 斐波那契数(动态规划和递归)
- 谷歌被曝出滥用苹果后门收集用户数据
- java线程池一创建就立马有线程了么_Java 线程池二之Executors创建的五种线程池及使用注意...
- 日历小程序C语言,微信小程序实现日历功能
- php继承 重写方法吗,PHP中的继承与重写
- Moodle 3.7安装
- ndk编译libiconv
- 如何用计算机制作思维导向图,mindmaster使用方法,手把手教你制作思维导图
- 微信开发工具出现 [渲染层网络层错误]
- CF 106C Buns
- 超越函数e^(-x^2)的定积分
- HyperLPR3车牌识别-Linux/MacOS使用:C/C++库编译
热门文章
- JavaScript校验网址
- Unexpected end of JSON input while parsing near错误解决方式(网上的方法)
- 合并Spark社区代码的正确姿势
- 上海女白领吃火锅碰瓷,支付宝口碑居然真的要赔?
- Git 简单命令行指令
- GNU make manual 翻译(四十三)
- 中小企业信息化,“轻”和“快”是方向
- 在C#中使用SQLite
- AdonisUI - 用于 WPF 应用程序的轻量级 UI 工具包,提供经典但增强的 Windows 视觉效果...
- C#中的表达式和运算符