|
| 1 | +# 性能测试 |
| 2 | +可以使用[`wrk`](https://github.com/wg/wrk)或其他工具(`ab`命令比较老旧,不建议使用)对TeaWeb进行压力性能测试。 |
| 3 | + |
| 4 | +以下拿一个虚拟机作为示例: |
| 5 | +* 硬件:配置为2G内存、双核CPU,单核频率为2.4G |
| 6 | +* 操作系统:CentOS v7.5.1804 |
| 7 | +* TeaWeb:版本为v0.1.8 |
| 8 | + |
| 9 | +## 命令说明 |
| 10 | +`-c`为并发连接数,`-t`为线程数,`-d`为测试持续时间,默认单位为秒。 |
| 11 | + |
| 12 | +## 静态文件测试 |
| 13 | +文件尺寸为:516B,测试命令: |
| 14 | +~~~bash |
| 15 | +/opt/wrk -c 1000 -t 16 -d 60 "http://192.168.2.30:8081/index.html" |
| 16 | +~~~ |
| 17 | + |
| 18 | +开启日志和统计的测试结果: |
| 19 | +~~~ |
| 20 | +Running 1m test @ http://192.168.2.30:8081/index.html |
| 21 | + 16 threads and 1000 connections |
| 22 | + Thread Stats Avg Stdev Max +/- Stdev |
| 23 | + Latency 92.37ms 75.08ms 896.79ms 68.53% |
| 24 | + Req/Sec 741.97 188.51 2.48k 79.70% |
| 25 | + 708650 requests in 1.00m, 348.72MB read |
| 26 | +Requests/sec: 11797.25 |
| 27 | +~~~ |
| 28 | + |
| 29 | +关闭日志和统计的测试结果: |
| 30 | +~~~ |
| 31 | +Running 1m test @ http://192.168.2.30:8081/index.html |
| 32 | + 16 threads and 1000 connections |
| 33 | + Thread Stats Avg Stdev Max +/- Stdev |
| 34 | + Latency 48.80ms 11.92ms 143.85ms 85.50% |
| 35 | + Req/Sec 1.28k 121.86 2.19k 69.84% |
| 36 | + 1218313 requests in 1.00m, 599.53MB read |
| 37 | +Requests/sec: 20278.17 |
| 38 | +Transfer/sec: 9.98MB |
| 39 | +~~~ |
| 40 | + |
| 41 | +## 代理测试 |
| 42 | +代理后端的一个用Apache服务的gif图片文件,尺寸为2.6kb,Apache服务同TeaWeb在同一台服务器上,测试命令: |
| 43 | +~~~bash |
| 44 | +/opt/wrk -c 1000 -t 16 -d 60 "http://192.168.2.30:8081/images/apache_pb.gif" |
| 45 | +~~~ |
| 46 | + |
| 47 | +开启日志和统计的测试结果: |
| 48 | +~~~ |
| 49 | +Running 1m test @ http://192.168.2.30:8081/images/apache_pb.gif |
| 50 | + 16 threads and 1000 connections |
| 51 | + Thread Stats Avg Stdev Max +/- Stdev |
| 52 | + Latency 220.60ms 79.02ms 810.65ms 88.32% |
| 53 | + Req/Sec 285.02 109.75 550.00 70.08% |
| 54 | + 271933 requests in 1.00m, 678.58MB read |
| 55 | +Requests/sec: 4525.87 |
| 56 | +Transfer/sec: 11.29MB |
| 57 | +~~~ |
| 58 | + |
| 59 | +关闭日志和统计的测试结果: |
| 60 | +~~~ |
| 61 | +Running 1m test @ http://192.168.2.30:8081/images/apache_pb.gif |
| 62 | + 16 threads and 1000 connections |
| 63 | + Thread Stats Avg Stdev Max +/- Stdev |
| 64 | + Latency 151.39ms 18.79ms 539.18ms 74.86% |
| 65 | + Req/Sec 411.13 87.49 787.00 67.26% |
| 66 | + 393091 requests in 1.00m, 0.96GB read |
| 67 | +Requests/sec: 6541.07 |
| 68 | +Transfer/sec: 16.32MB |
| 69 | +~~~ |
| 70 | + |
| 71 | +当然,具体测试的时候,后端服务最好是静态文件,以便消除因为后端服务的速度太慢而导致测试结果低下的问题。 |
| 72 | + |
| 73 | +## 资源释放情况 |
| 74 | +测试完成后,内存迅速恢复到95M左右,CPU恢复到5%以下。 |
0 commit comments