使用 MySQL 线程池对压力测试的影响

使用 MySQL 线程池对压力测试的影响,下面使用两个文件,分别测试一下。


代码:

test1.js 使用了 MySQL 线程池:

export async function test1(ctx) {
 let pool = dbUtil.getPool();
 let connection = await pool.getConnection();
 let [rows] = await connection.query('select * from tb_user limit 10');
 connection.release();
}

test2.js 未使用 MySQL 线程池:

export async function test2(ctx) {
 var rows = await dbUtil.query('select * from tb_user limit 10');
 ctx.body = rows;
}

压测命令:

ab -c 200 -n 9999 http://127.0.0.1:8001/test1


执行结果:

test1.js 的结果:

Server Software:     
Server Hostname:    127.0.0.1
Server Port:      8001

Document Path:     /test1
Document Length:    3140 bytes

Concurrency Level:   200
Time taken for tests:  37.411 seconds
Complete requests:   9999
Failed requests:    0
Total transferred:   32836716 bytes
HTML transferred:    31396860 bytes
Requests per second:  267.28 [#/sec] (mean)
Time per request:    748.287 [ms] (mean)
Time per request:    3.741 [ms] (mean, across all concurrent requests)
Transfer rate:     857.17 [Kbytes/sec] received

Connection Times (ms)
       min mean[+/-sd] median  max
Connect:    0  1  7.2   0   123
Processing:  19 743 93.1  744  1011
Waiting:    4 686 90.3  685   953
Total:     19 744 93.7  745  1084

Percentage of the requests served within a certain time (ms)
 50%  745
 66%  778
 75%  800
 80%  816
 90%  861
 95%  908
 98%  947
 99%  977
 100%  1084 (longest request)


test2.js 的结果:

Server Software:     
Server Hostname:    127.0.0.1
Server Port:      8001

Document Path:     /test2
Document Length:    3140 bytes

Concurrency Level:   200
Time taken for tests:  11.595 seconds
Complete requests:   9999
Failed requests:    0
Total transferred:   32836716 bytes
HTML transferred:    31396860 bytes
Requests per second:  862.39 [#/sec] (mean)
Time per request:    231.914 [ms] (mean)
Time per request:    1.160 [ms] (mean, across all concurrent requests)
Transfer rate:     2765.71 [Kbytes/sec] received

Connection Times (ms)
       min mean[+/-sd] median  max
Connect:    0  0  1.0   0   24
Processing:  14 228 69.6  202   461
Waiting:    3 227 69.4  201   461
Total:     14 229 69.6  202   461

Percentage of the requests served within a certain time (ms)
 50%  202
 66%  217
 75%  240
 80%  258
 90%  354
 95%  393
 98%  440
 99%  454
 100%  461 (longest request)



真诚赞赏,手留余香
赞赏
操作系统
Debian11 安装笔记4:安装常用软件
2022-08-23
MySQL
MySQL的外键总结
2022-09-15
ngtwewy
随机推荐
JavaScript 的异步 IO 和事件循环概念
nginx 的过时模式 TLS 1.0 或 TLS 1.1 被起用,无法禁止的解决办法
Linux apt 命令
Node.js 断言模块 Assert 模块
JavaScript console 的用法
CSS 实现夜间模式和CSS自定义属性(变量)
SVG 图标制作指南
数据库中间表应该如何命名
如何使用命令修改 MySQL 数据库名称
nginx 代理

微信联系我

夜间模式切换
回到顶部