找回密码
 立即注册
首页 业界区 业界 留个VKProxy性能测试记录

留个VKProxy性能测试记录

饨篦 6 小时前
其实原本是打算OpenTelemetry对应内容搞好后再做个简单的性能测试,也算表明自己写(抄)代码的能力(不至于用了反射什么的就把Kestrel这么好的底子的性能拖垮了)
但是最近看见一篇go的文章 报告揭示 OpenTelemetry 对 Go 的性能影响,说OpenTelemetry 拖慢了 go 30+% 的性能,
虽然个人还是保守持怀疑态度,但万一本人代码写得臭,到时候找不到地方怪怎么办
所以先留份简单的性能测试记录,后面搞好OpenTelemetry再做个比较
基准项目

一切从简,就选大家都熟悉的初始demo项目做基准好了
  1. [ApiController]
  2. [Route("[controller]")]
  3. public class WeatherForecastController : ControllerBase
  4. {
  5.     private static readonly string[] Summaries = new[]
  6.     {
  7.         "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  8.     };
  9.     private readonly ILogger<WeatherForecastController> _logger;
  10.     public WeatherForecastController(ILogger<WeatherForecastController> logger)
  11.     {
  12.         _logger = logger;
  13.     }
  14.     [HttpGet(Name = "GetWeatherForecast")]
  15.     public IEnumerable<WeatherForecast> Get()
  16.     {
  17.         this.Response.Headers["x-p"] = this.Request.Protocol;
  18.         return Enumerable.Range(1, 5).Select(index => new WeatherForecast
  19.         {
  20.             Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
  21.             TemperatureC = Random.Shared.Next(-20, 55),
  22.             Summary = Summaries[Random.Shared.Next(Summaries.Length)]
  23.         })
  24.         .ToArray();
  25.     }
  26. }
复制代码
代理配置

启动最简单的代理配置(主要想看看最理想情况下的结果)
  1. {
  2.   "Logging": {
  3.     "LogLevel": {
  4.       "Default": "Warning"
  5.     }
  6.   },
  7.   "ServerOptions": {
  8.     "AddServerHeader": false
  9.   },
  10.   "ReverseProxy": {
  11.     "ConnectionTimeout": "00:00:01.000",
  12.     "Listen": {
  13.       "https": {
  14.         "Protocols": [ "Http1", "Http2", "Http3" ],
  15.         "Address": [ "127.0.0.1:5001" ],
  16.         "UseSni": true,
  17.         "SniId": "test"
  18.       },
  19.       "http": {
  20.         "Protocols": [ "Http1" ],
  21.         "Address": [ "127.0.0.1:5000" ]
  22.       },
  23.       "tcptest": {
  24.         "Protocols": [ "Tcp" ],
  25.         "Address": [ "127.0.0.1:5002" ],
  26.         "RouteId": "tcpTest"
  27.       }
  28.     },
  29.     "Sni": {
  30.       "test": {
  31.         "Host": [ "*" ],
  32.         "CheckCertificateRevocation": false,
  33.         "Certificate": {
  34.           "PEM": "-----BEGIN CERTIFICATE-----xxxxx\n-----END CERTIFICATE-----",
  35.           "PEMKey": "-----BEGIN ENCRYPTED PRIVATE KEY-----\nxxxx\n-----END ENCRYPTED PRIVATE KEY-----",
  36.           "Password": "testPassword"
  37.         }
  38.       }
  39.     },
  40.     "Routes": {
  41.       "HTTPTEST": {
  42.         "Match": {
  43.           "Hosts": [ "*" ],
  44.           "Paths": [ "*" ]
  45.         },
  46.         "ClusterId": "apidemo",
  47.         "Timeout": "00:10:11"
  48.       },
  49.       "tcpTest": {
  50.         "ClusterId": "apidemo",
  51.         "Timeout": "00:10:11"
  52.       }
  53.     },
  54.     "Clusters": {
  55.       "apidemo": {
  56.         "HttpClientConfig": {
  57.           "DangerousAcceptAnyServerCertificate": true
  58.         },
  59.         "LoadBalancingPolicy": "RoundRobin",
  60.         "Destinations": [
  61.           {
  62.             "Address": "https://127.0.0.1:4001"
  63.           }
  64.         ]
  65.       }
  66.     }
  67.   }
  68. }
复制代码
  1. 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
测试命令
  1. // 性能测试
  2. .\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=test -output=results -http2
  3. // 汇总报告
  4. .\vegeta.exe report .\results
  5. // 绘图
  6. .\vegeta.exe plot .\results  > plot.html
复制代码
测试结果

基准 HTTP2 -> WeatherForecast api
  1. .\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=base -output=baseresults -http2
  2. // base content:
  3. // GET https://127.0.0.1:4001/WeatherForecast
复制代码
1.jpeg

2.jpeg

汇总
  1. Requests      [total, rate, throughput]         599930, 9998.35, 9998.35
  2. Duration      [total, attack, wait]             1m0s, 1m0s, 0s
  3. Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 676.024µs, 0s, 2.56ms, 3.705ms, 5.367ms, 26.437ms
  4. Bytes In      [total, mean]                     232052167, 386.80
  5. Bytes Out     [total, mean]                     0, 0.00
  6. Success       [ratio]                           100.00%
  7. Status Codes  [code:count]                      200:599930
  8. Error Set:
复制代码
HTTP2 -> VKProxy(https) -> HTTP2 -> WeatherForecast api
  1. .\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=http2proxy -output=http2proxyresults -http2
  2. // http2proxy content:
  3. // GET https://127.0.0.1:5001/WeatherForecast
复制代码
3.jpeg

4.jpeg

汇总
  1. Requests      [total, rate, throughput]         599980, 9999.85, 9999.85
  2. Duration      [total, attack, wait]             59.999s, 59.999s, 0s
  3. Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 2.199ms, 1.845ms, 5.162ms, 6.359ms, 9.217ms, 108.78ms
  4. Bytes In      [total, mean]                     232078680, 386.81
  5. Bytes Out     [total, mean]                     0, 0.00
  6. Success       [ratio]                           100.00%
  7. Status Codes  [code:count]                      200:599980
  8. Error Set:
复制代码
HTTP2 -> VKProxy(tcp) -> scoket -> WeatherForecast api
  1. .\vegeta.exe attack -insecure -rate=10000/s -duration=60s -format=http -targets=tcpproxy -output=tcpproxyresults -http2
  2. // tcpproxy content:
  3. // GET https://127.0.0.1:5002/WeatherForecast
复制代码
5.jpeg

6.jpeg

汇总
  1. Requests      [total, rate, throughput]         599976, 9998.48, 9998.48
  2. Duration      [total, attack, wait]             1m0s, 1m0s, 0s
  3. Latencies     [min, mean, 50, 90, 95, 99, max]  0s, 1.809ms, 1.004ms, 4.736ms, 5.744ms, 8.995ms, 98.922ms
  4. Bytes In      [total, mean]                     232069758, 386.80
  5. Bytes Out     [total, mean]                     0, 0.00
  6. Success       [ratio]                           100.00%
  7. Status Codes  [code:count]                      200:599976
  8. Error Set:
复制代码
结果大致就是这样了,看起来个人写的代码也不至于太臭,至少理想情况下没有拖慢多少,
客官,你们怎么看?
VKProxy 是使用c#开发的基于 Kestrel 实现 L4/L7的代理(感兴趣的同学烦请点个github小赞赞呢)

来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册