.NET Core 2 基准测试,req/s 远低于预期
.NET Core 2 Benchmarking, req/s far below what's expected
我今天是 运行 一个空的 .NET Core Web 应用程序的任意基准测试,并且对 req/s 数字始终如此之低感到失望。我见过 examples online where people are getting 50-60k req/s, some 和 1.15M req/s 一样疯狂,我的时钟在 1-2.5k 之间。
我的机器规格:
代码:
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.IO;
namespace NetCore
{
public class Startup
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
}
}
我 运行 使用 release 配置,目标 netcoreapp2.1
:
dotnet publish -c release -f netcoreapp2.1
我正在使用 bombardier 进行基准测试:
bombardier http://localhost:5000 -c 250 -d 30s
结果:
只是想知道我是否遗漏了一些明显的东西。或者做错了什么。
为了跟踪,我在 GitHub 上发布了一个 issue。
简答:您的 CPU 是 i7-7500U @2.70G @2.90G
这里i7-7500U
中的字母U
代表Ultra Low Voltage
,也就是说你的CPU即使和Core比起来也没那么强大i4 带有字母 HQ、HK,或者根本没有字母。
请注意,那些在线基准测试通常使用更强大的 CPU 。例如,处理 97.9K req/sec 的 Benchmarking here 使用 Intel(R) Core(TM) i7–4710HQ CPU @ 2.50GHz 2.50GHz
.
的处理器
我认为基准测试不重要。因为我们总会有不同的硬件、不同的 OS 、不同的进程 运行 和不同的网络。但是,作为证明 CPU 确实重要的示例,我将您的代码的基准标记粘贴到我的计算机(Core(TM) i7-4900 @3.6GHz @3.6GHz)上,如下所示:
>bombardier.exe http://localhost:5000 -c 250 -d 30s
Bombarding http://localhost:5000 for 30s using 250 connection(s)
[============================================ ================================================ ===================] 30s
完成!
统计平均标准偏差最大值
eqs/sec 9625.47 1759.59 13165.59
延迟 25.94ms 498.77us 73.96ms
HTTP 代码:
1xx - 0、2xx - 289210、3xx - 0、4xx - 0、5xx - 0
其他 - 0
吞吐量:1.70MB/秒
可能有 Information
级别的控制台日志记录? (还有更快的日志记录形式)
尝试通过添加 appsettings.json
文件将其减少到 Warning
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
}
}
还要确保您使用的是 Server GC; .csproj
的顶部应该在末尾有 .Web
<Project Sdk="Microsoft.NET.Sdk.Web">
你也是运行发布的dll?
dotnet bin\release\netcoreapp2.1\publish\myapp.dll
我今天是 运行 一个空的 .NET Core Web 应用程序的任意基准测试,并且对 req/s 数字始终如此之低感到失望。我见过 examples online where people are getting 50-60k req/s, some 和 1.15M req/s 一样疯狂,我的时钟在 1-2.5k 之间。
我的机器规格:
代码:
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using System.IO;
namespace NetCore
{
public class Startup
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
public void ConfigureServices(IServiceCollection services)
{
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
}
}
我 运行 使用 release 配置,目标 netcoreapp2.1
:
dotnet publish -c release -f netcoreapp2.1
我正在使用 bombardier 进行基准测试:
bombardier http://localhost:5000 -c 250 -d 30s
结果:
只是想知道我是否遗漏了一些明显的东西。或者做错了什么。
为了跟踪,我在 GitHub 上发布了一个 issue。
简答:您的 CPU 是 i7-7500U @2.70G @2.90G
这里
i7-7500U
中的字母U
代表Ultra Low Voltage
,也就是说你的CPU即使和Core比起来也没那么强大i4 带有字母 HQ、HK,或者根本没有字母。请注意,那些在线基准测试通常使用更强大的 CPU 。例如,处理 97.9K req/sec 的 Benchmarking here 使用
Intel(R) Core(TM) i7–4710HQ CPU @ 2.50GHz 2.50GHz
. 的处理器
我认为基准测试不重要。因为我们总会有不同的硬件、不同的 OS 、不同的进程 运行 和不同的网络。但是,作为证明 CPU 确实重要的示例,我将您的代码的基准标记粘贴到我的计算机(Core(TM) i7-4900 @3.6GHz @3.6GHz)上,如下所示:
>bombardier.exe http://localhost:5000 -c 250 -d 30s Bombarding http://localhost:5000 for 30s using 250 connection(s)
[============================================ ================================================ ===================] 30s
完成!
统计平均标准偏差最大值
eqs/sec 9625.47 1759.59 13165.59
延迟 25.94ms 498.77us 73.96ms
HTTP 代码:
1xx - 0、2xx - 289210、3xx - 0、4xx - 0、5xx - 0
其他 - 0
吞吐量:1.70MB/秒
可能有 Information
级别的控制台日志记录? (还有更快的日志记录形式)
尝试通过添加 appsettings.json
文件将其减少到 Warning
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
}
}
还要确保您使用的是 Server GC; .csproj
的顶部应该在末尾有 .Web
<Project Sdk="Microsoft.NET.Sdk.Web">
你也是运行发布的dll?
dotnet bin\release\netcoreapp2.1\publish\myapp.dll