Spring Boot 2 Webflux基准测试很可怕,我做错了什么?我的机器是一个新的macbook pro。
Spring 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");
}
Spring Boot 2 M7解决了这个问题。
但它仍然比ASP .NET Core 2慢得多
ASP .NET CORE请求数/秒:~65000.00
Spring Boot 2 M7请求数/秒:~28000.00
使用MVC(没有数据库,只有简单的控制器返回文本)