惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - victor.x.qu

如何用c# 做 mcp/ChatGPT app 春节期间浅试了 ai 视频生成 举个栗子:做个AI Gateway demo 2025个人总结 实现 json path 来评估函数式解析器的损耗 VKProxy 集成 OpenTelemetry c# ACME client (补充) c# ACME client VKProxy新增一些功能 http流量镜像 VKProxy新增CORS设置和http响应缓存 VKProxy新增速率限制功能 VKProxy已提供命令行工具,镜像和简单的ui 已经在为VKProxy写UI配置站点和文档了 莫想到有一天得重新写个 etcd client 如何使用 websocket 完成 socks5 网络穿透 如何基于 Kestrel 实现 socks5 代理 记录一下 简单udp和sni 代理 done 终于写完轮子一部分:tcp代理 了,记录一下
留个VKProxy性能测试记录
victor.x.qu · 2025-07-11 · via 博客园 - victor.x.qu

其实原本是打算OpenTelemetry对应内容搞好后再做个简单的性能测试,也算表明自己写(抄)代码的能力(不至于用了反射什么的就把Kestrel这么好的底子的性能拖垮了)

但是最近看见一篇go的文章 报告揭示 OpenTelemetry 对 Go 的性能影响,说OpenTelemetry 拖慢了 go 30+% 的性能,

虽然个人还是保守持怀疑态度,但万一本人代码写得臭,到时候找不到地方怪怎么办

所以先留份简单的性能测试记录,后面搞好OpenTelemetry再做个比较

基准项目

一切从简,就选大家都熟悉的初始demo项目做基准好了

[ApiController]
[Route("[controller]")]
public class WeatherForecastController : ControllerBase
{
    private static readonly string[] Summaries = new[]
    {
        "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
    };

    private readonly ILogger<WeatherForecastController> _logger;

    public WeatherForecastController(ILogger<WeatherForecastController> logger)
    {
        _logger = logger;
    }

    [HttpGet(Name = "GetWeatherForecast")]
    public IEnumerable<WeatherForecast> Get()
    {
        this.Response.Headers["x-p"] = this.Request.Protocol;
        return Enumerable.Range(1, 5).Select(index => new WeatherForecast
        {
            Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
            TemperatureC = Random.Shared.Next(-20, 55),
            Summary = Summaries[Random.Shared.Next(Summaries.Length)]
        })
        .ToArray();
    }
}

代理配置

启动最简单的代理配置(主要想看看最理想情况下的结果)

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "ServerOptions": {
    "AddServerHeader": false
  },
  "ReverseProxy": {
    "ConnectionTimeout": "00:00:01.000",
    "Listen": {
      "https": {
        "Protocols": [ "Http1", "Http2", "Http3" ],
        "Address": [ "127.0.0.1:5001" ],
        "UseSni": true,
        "SniId": "test"
      },
      "http": {
        "Protocols": [ "Http1" ],
        "Address": [ "127.0.0.1:5000" ]
      },
      "tcptest": {
        "Protocols": [ "Tcp" ],
        "Address": [ "127.0.0.1:5002" ],
        "RouteId": "tcpTest"
      }
    },
    "Sni": {
      "test": {
        "Host": [ "*" ],
        "CheckCertificateRevocation": false,
        "Certificate": {
          "PEM": "-----BEGIN CERTIFICATE-----xxxxx\n-----END CERTIFICATE-----",
          "PEMKey": "-----BEGIN ENCRYPTED PRIVATE KEY-----\nxxxx\n-----END ENCRYPTED PRIVATE KEY-----",
          "Password": "testPassword"
        }
      }
    },
    "Routes": {
      "HTTPTEST": {
        "Match": {
          "Hosts": [ "*" ],
          "Paths": [ "*" ]
        },
        "ClusterId": "apidemo",
        "Timeout": "00:10:11"
      },
      "tcpTest": {
        "ClusterId": "apidemo",
        "Timeout": "00:10:11"
      }
    },
    "Clusters": {
      "apidemo": {
        "HttpClientConfig": {
          "DangerousAcceptAnyServerCertificate": true
        },
        "LoadBalancingPolicy": "RoundRobin",
        "Destinations": [
          {
            "Address": "https://127.0.0.1:4001"
          }
        ]
      }
    }
  }
}
vkproxy -c D:\code\github\VKProxy\samples\CoreDemo\test.json

测试工具

这里会在本人电脑内测试理想情况,主要没有精力去搭建真实网络环境测试(贫穷的眼泪),哈哈

个人电脑情况:
Windows 11 (10.0.26100.4351)
Intel Core i7-10700 CPU 2.90GHz, 1 CPU, 16 logical and 8 physical cores
32G Memory
INTEL SSDPEKNW512GB

以前用过 ali 这个go写的测试工具,因为它会实时在命令行终端绘制性能测试图,在简单测试使用很方便,但可惜断更了,并且有个大bug没有修复:绘制的性能测试图错位了,非常影响观看,非常惋惜呀

所以这里找了个同样go写的工具 vegeta 主要看重它有命令可以生成图, 但可惜好像不支持 http3

测试命令

// 性能测试
.\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=test -output=results -http2 

// 汇总报告
.\vegeta.exe report .\results

// 绘图
.\vegeta.exe plot .\results  > plot.html

测试结果

基准 HTTP2 -> WeatherForecast api

.\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=base -output=baseresults -http2 
// base content:
// GET https://127.0.0.1:4001/WeatherForecast

base

baseplot

汇总

Requests      [total, rate, throughput]         599930, 9998.35, 9998.35
Duration      [total, attack, wait]             1m0s, 1m0s, 0s
Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 676.024µs, 0s, 2.56ms, 3.705ms, 5.367ms, 26.437ms
Bytes In      [total, mean]                     232052167, 386.80
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:599930
Error Set:

HTTP2 -> VKProxy(https) -> HTTP2 -> WeatherForecast api

.\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=http2proxy -output=http2proxyresults -http2 
// http2proxy content:
// GET https://127.0.0.1:5001/WeatherForecast

HTTP2

http2plot

汇总

Requests      [total, rate, throughput]         599980, 9999.85, 9999.85
Duration      [total, attack, wait]             59.999s, 59.999s, 0s
Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 2.199ms, 1.845ms, 5.162ms, 6.359ms, 9.217ms, 108.78ms
Bytes In      [total, mean]                     232078680, 386.81
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:599980
Error Set:

HTTP2 -> VKProxy(tcp) -> scoket -> WeatherForecast api

.\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=tcpproxy -output=tcpproxyresults -http2 
// tcpproxy content:
// GET https://127.0.0.1:5002/WeatherForecast

tcp

tcpplot

汇总

Requests      [total, rate, throughput]         599976, 9998.48, 9998.48
Duration      [total, attack, wait]             1m0s, 1m0s, 0s
Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 1.809ms, 1.004ms, 4.736ms, 5.744ms, 8.995ms, 98.922ms
Bytes In      [total, mean]                     232069758, 386.80
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           100.00%
Status Codes  [code:count]                      200:599976
Error Set:

结果大致就是这样了,看起来个人写的代码也不至于太臭,至少理想情况下没有拖慢多少,

客官,你们怎么看?

VKProxy 是使用c#开发的基于 Kestrel 实现 L4/L7的代理(感兴趣的同学烦请点个github小赞赞呢)