GenHTTP on .NET 11 登顶HTTP Arena 多个榜单(这是何方神圣)

今天偶尔刷到Http Arena 的排行榜, https://www.http-arena.com/,这个是TechEmpower 榜单不再更新后,一个相对全的性能测评榜单。

所以看见C# 的GenHTTP登顶了多个榜单很是震惊,不是单项强,是综合都很强。

很多细分榜单第一,大多不是第一的也排名靠前或者和第一差距很小的情形。 大家可以自行判断下。

这个是介绍:

GenHTTP 11 on .NET 11 on a custom io_uring server engine (the ioxide runtime) instead of the default socket engine. Built from the GenHTTP 11 preview 24 packages, which carry the merged ioxide engine branch (PR #887): TLS is terminated in the engine itself, with HTTP/2 and HTTP/3: :8080 is HTTP/1.1, :8082 h2c, :8081 HTTP/1.1 over TLS, and :8443 serves HTTP/1.1 and HTTP/2 over TCP plus HTTP/3 over QUIC on the same port. Static is served by IoxideFiles, which reads bodies positionally off the io_uring ring through a per-reactor descriptor snapshot; responses go through GenHTTP's own routing + serialization; Postgres rides ioxide.pg (per-reactor ring-native pool).

https://github.com/Kaliumhexacyanoferrat/GenHTTP

https://genhttp.org/

稍微研究了一下发现几个事实:

  1. 达到这个成绩基于.net的io_turing引擎, ioxide 是一个专门为 .NET 做的高性能 Linux I/O Runtime 。它不是普通的 HTTP Server,也不是 io_uring 本身;更准确地说,它是在 .NET 上重新实现了一套基于 Linux io_uring 的 shared-nothing reactor 网络执行模型。

  2. HttpArena 对这个版本的描述非常明确:

GenHTTP 11 + .NET 11 + custom io_uring server engine(ioxide),而不是默认 socket engine。

而且 HTTP/2、HTTP/3、TLS 都是在这个 engine 上跑的。

所以实际上可以把架构理解成:

复制代码
                ┌──────────────────────┐
                │       GenHTTP        │
                │                      │
                │ Router               │
                │ Handler              │
                │ Serialization        │
                │ Middleware           │
                └──────────┬───────────┘
                           │
                    HTTP abstraction
                           │
                ┌──────────▼───────────┐
                │       ioxide         │
                │                      │
                │ HTTP/1.1             │
                │ HTTP/2               │
                │ HTTP/3               │
                │ TLS                  │
                └──────────┬───────────┘
                           │
                    io_uring
                           │
                ┌──────────▼───────────┐
                │       Linux          │
                │       Kernel         │
                └──────────────────────┘

而传统 ASP.NET Core/Kestrel 更接近:

复制代码
Application
     │
 ASP.NET Core
     │
   Kestrel
     │
 Socket APIs
     │
 .NET ThreadPool / async infrastructure
     │
 Linux

3. 最大的杀手锏:Shared-Nothing

这是我认为整个项目最值得研究的地方。

ioxide 的设计原则非常激进:

one reactor per core

每一个 CPU core 有自己的 reactor:

复制代码
CPU Core 0
 └── Reactor 0
      ├── io_uring ring
      ├── connections
      ├── clients
      ├── connection state
      └── handlers

CPU Core 1
 └── Reactor 1
      ├── io_uring ring
      ├── connections
      ├── clients
      └── handlers

CPU Core 2
 └── Reactor 2
      ...

关键是:

一个 request 尽可能始终留在它进入的 CPU core 上。

ioxide 官方描述的设计就是:

  • 每个 reactor 一个 io_uring ring
  • 每个 reactor 一个 core
  • 每个 reactor 自己拥有 connections
  • 每个 reactor 自己拥有 clients
  • 请求不会跨 core
  • 尽量不需要 lock

成绩相关截图:

HTTP 1.1 相关:

HTTP/2:

H3:

WebSocket:

相关推荐
淡海水10 小时前
01-04-认知篇-Unity内存全景
unity·c#·游戏引擎·.net·gc
JosieBook12 小时前
【.NET工程师】.NET 工程师成长体系(精要版)
.net
淡海水21 小时前
01-03-认知篇-C#内存模型深度解析
unity·c#·游戏引擎·.net·gc
AKULAKK2 天前
关于在Ghost版Win7上运行.net 2程序遇到的问题以及解决办法
.net·win7
波力海苔夹心脆6752 天前
C# 序列化与反序列化详解:System.Text.Json、Newtonsoft.Json、XmlSerializer 用法、特性选项与安全实践
经验分享·后端·c#·json·.net
mudtools2 天前
在.NET现有系统中快速集成飞书任务分配能力
后端·c#·.net
小羊没烦恼!2 天前
【译】利用Asp.net MVC处理文件的上传下载
开发语言·缓存·c#·word·powerpoint·.net
唐青枫4 天前
我用 C# 开发了一款电子发票自动整理工具
c#·.net
我是唐青枫4 天前
我用 C# 开发了一款电子发票自动整理工具
c#·.net
唐青枫4 天前
别把 WPF 写成一个 MainWindow:C#.NET Prism 模块化开发详解
c#·.net