tio-boot vs Quarkus 性能对比测试报告
1. 测试目的
对比 tio-boot 与 Quarkus 在相同硬件环境、相同并发模型下的 HTTP /plaintext 接口性能,重点关注:
- 吞吐量(Requests Per Second, RPS)
- 平均延迟
- 尾延迟(P99 / Max)
- 在 Keep-Alive 场景下的稳定性
该测试主要反映 网络框架与执行链路的极限性能,不涉及数据库、磁盘 IO 等业务逻辑。
2. 测试环境
操作系统:Linux(Debian)
CPU:16 核
网络:本地回环(127.0.0.1)
压测工具:ApacheBench 2.3
JVM:支持虚拟线程(JDK 21+)
并发参数:
-n 1000000-c 100-k(Keep-Alive 开启)
3. 测试接口说明
3.1 测试接口
| 框架 | 接口 | 返回内容 | 响应大小 |
|---|---|---|---|
| tio-boot | /plaintext | 纯文本 | 13 bytes |
| Quarkus | /plaintext | 纯文本 | 13 bytes |
本轮对比已 统一响应大小,保证测试公平性。
3.2 测试代码tio-boot
package com.litongjava.tio.boot.benchmarker.handler;
import com.litongjava.tio.boot.http.TioRequestContext;
import com.litongjava.tio.http.common.HeaderName;
import com.litongjava.tio.http.common.HeaderValue;
import com.litongjava.tio.http.common.HttpRequest;
import com.litongjava.tio.http.common.HttpResponse;
import com.litongjava.tio.http.server.handler.HttpRequestHandler;
public class PlaintextHandler implements HttpRequestHandler {
private static final String HELLO_WORLD = "Hello, World!";
private static final byte[] HELLO_WORLD_BYTES = HELLO_WORLD.getBytes();
@Override
public HttpResponse handle(HttpRequest httpRequest) throws Exception {
HttpResponse response = TioRequestContext.getResponse();
response.setBody(HELLO_WORLD_BYTES);
response.addHeader(HeaderName.Content_Type, HeaderValue.Content_Type.TEXT_PLAIN_TXT);
return response;
}
}
3.3 测试代码quarkus
package org.acme;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
@Path("/plaintext")
public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello, World!";
}
}
4. 测试结果汇总
4.1 tio-boot 测试结果
(base) root@debian:~# ab -k -n1000000 -c100 http://127.0.0.1:8080/plaintext
This is ApacheBench, Version 2.3 <$Revision: 1923142 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Completed 1000000 requests
Finished 1000000 requests
Server Software: -io
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /plaintext
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 4.753 seconds
Complete requests: 1000000
Failed requests: 0
Keep-Alive requests: 1000000
Total transferred: 179000000 bytes
HTML transferred: 13000000 bytes
Requests per second: 210393.61 [#/sec] (mean)
Time per request: 0.475 [ms] (mean)
Time per request: 0.005 [ms] (mean, across all concurrent requests)
Transfer rate: 36777.79 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 3
Processing: 0 0 0.1 0 13
Waiting: 0 0 0.1 0 13
Total: 0 0 0.1 0 14
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 1
95% 1
98% 1
99% 1
100% 14 (longest request)
4.2 quarkus 测试结果
(base) root@debian:~# ab -k -n1000000 -c100 http://127.0.0.1:8080/plaintext
This is ApacheBench, Version 2.3 <$Revision: 1923142 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
Completed 400000 requests
Completed 500000 requests
Completed 600000 requests
Completed 700000 requests
Completed 800000 requests
Completed 900000 requests
Completed 1000000 requests
Finished 1000000 requests
Server Software:
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /plaintext
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 5.074 seconds
Complete requests: 1000000
Failed requests: 0
Keep-Alive requests: 1000000
Total transferred: 116000000 bytes
HTML transferred: 13000000 bytes
Requests per second: 197072.84 [#/sec] (mean)
Time per request: 0.507 [ms] (mean)
Time per request: 0.005 [ms] (mean, across all concurrent requests)
Transfer rate: 22324.66 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 3
Processing: 0 1 0.5 0 62
Waiting: 0 1 0.5 0 62
Total: 0 1 0.5 0 62
WARNING: The median and mean for the processing time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the waiting time are not within a normal deviation
These results are probably not that reliable.
WARNING: The median and mean for the total time are not within a normal deviation
These results are probably not that reliable.
Percentage of the requests served within a certain time (ms)
50% 0
66% 0
75% 0
80% 0
90% 1
95% 1
98% 1
99% 1
100% 62 (longest request)
4.3 tio-boot(虚拟线程版本)
Requests per second: 210,393.61
Time taken: 4.753 s
Mean latency: 0.475 ms
Keep-Alive requests: 1,000,000
P100 (max latency): 14 ms
特点:
- 吞吐稳定
- 延迟分布集中
- 尾延迟非常低
4.4 Quarkus(最新测试结果)
Requests per second: 197,072.84
Time taken: 5.074 s
Mean latency: 0.507 ms
Keep-Alive requests: 1,000,000
P100 (max latency): 62 ms
特点:
- 吞吐略低
- 延迟分布存在明显长尾
- ApacheBench 给出 “results are probably not that reliable” 警告,说明尾部抖动较明显
5. 核心指标对比
5.1 吞吐量(RPS)
| 框架 | RPS |
|---|---|
| tio-boot | 210,393 |
| Quarkus | 197,073 |
tio-boot 吞吐领先约:
[ \frac{210,393}{197,073} \approx \mathbf{1.067} ]
👉 约 +6.7%
5.2 平均延迟
| 框架 | Mean Latency |
|---|---|
| tio-boot | 0.475 ms |
| Quarkus | 0.507 ms |
👉 tio-boot 略优(约 6%)
5.3 尾延迟(关键差异)
| 指标 | tio-boot | Quarkus |
|---|---|---|
| Max latency | 14 ms | 62 ms |
👉 Quarkus 的最慢请求约为 tio-boot 的 4.4 倍
这也是 ApacheBench 对 Quarkus 给出 “NOT reliable / probably not reliable” 警告的主要原因。
6. 结果分析
6.1 为什么 tio-boot 尾延迟更低
- 更短的请求执行链路
- 更贴近网络层的 IO 模型
- 更少的中间抽象与上下文切换
- 在高频短请求场景下更容易保持调度稳定
6.2 为什么 Quarkus 吞吐略低、尾延迟更长
- 更完整的 HTTP / Web 框架能力
- 更丰富的上下文、拦截器、扩展点
- 设计目标偏向 开发效率与生态完整性,而非极限 benchmark
这属于架构取舍,而非实现优劣。
7. 关于虚拟线程的影响
在 tio-boot 测试中,引入虚拟线程后观察到:
- 吞吐小幅提升(~3%)
- 尾延迟显著下降(P100 从 30ms+ 降到 14ms)
说明在 高并发、短任务、偶发阻塞 场景下,虚拟线程对调度稳定性有实际价值。
8. 结论总结
适合选择 tio-boot 的场景
- 高吞吐、低延迟网络服务
- 网关 / 协议服务 / benchmark 型接口
- 对 P99 / P100 延迟敏感的系统
适合选择 Quarkus 的场景
- 标准 HTTP / REST 服务
- 微服务架构
- 更关注开发效率、生态与可维护性
9. 一句话结论
在相同测试条件下, tio-boot 在吞吐量上领先 Quarkus 约 6–7%,并显著优于其尾延迟表现; Quarkus 提供更完整的 Web 能力,但在极限性能场景下存在更明显的长尾。
