Spring Boot Sping Boot 2 Webflux基准测试与asp.net core 2相比很糟糕

l0oc07j2  于 2023-02-04  发布在  Spring
关注(0)|答案(2)|浏览(179)

Sping Boot 2 Webflux基准测试太可怕了,我做错了什么?我的机器是新的MacBook Pro。
Sping Boot 2 M6基准测试(禁用日志)

wrk -t8 -c1024 --timeout 10 http://localhost:8080/api/values/1
    Running 10s test @ http://localhost:8080/api/values/1
      8 threads and 1024 connections
      Thread Stats   Avg      Stdev     Max   +/- Stdev
        Latency    65.35ms  225.96ms   3.32s    97.16%
        Req/Sec     0.86k   329.15     1.78k    73.01%
      58374 requests in 10.09s, 6.01MB read
      Socket errors: connect 781, read 223, write 0, timeout 0
    Requests/sec:   5785.15
    Transfer/sec:    610.18KB

ASP.net Core 2(禁用日志)

wrk -t8 -c1024 --timeout 10 http://localhost:5000/api/values/1
Running 10s test @ http://localhost:5000/api/values/1
  8 threads and 1024 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.66ms   10.37ms 286.49ms   98.91%
    Req/Sec     8.84k     7.72k   23.10k    62.05%
  413298 requests in 10.06s, 85.53MB read
  Socket errors: connect 781, read 238, write 3, timeout 0
Requests/sec:  41092.22
Transfer/sec:      8.50MB

我使用开箱即用的入门配置和简单的端点:
JAVA语言

@GetMapping(value="/{id}",produces = "application/json")
    public Mono<String> getValue(@PathVariable Long id)
    {
        return Mono.just("value");
    }
}

C#

[HttpGet("{id}")]
        [Produces("application/json")]
        public IActionResult Get(int id)
        {
            return Ok("value");
        }
jtw3ybtb

jtw3ybtb1#

Sping Boot 2 M7修复了此问题。
但它仍然比ASP.NET核心2慢得多
ASP.NET核心请求数/秒:约65000美元
Sping Boot 2 M7请求/秒:约28,000美元
使用MVC(没有数据库,只有一个简单的控制器返回文本)

wpcxdonn

wpcxdonn2#

你的配置是什么?我运行了spring Boot v3.0(默认)+ webflux vs ASP.NET minimal,两个都达到了4.7k req/s的最大值,调用了下面这个简单而愚蠢的Hello端点:

ab -n 10000 -c 10 http://localhost:8080/hello

相关问题