性能与压测

mysql压测

2018-07-20  本文已影响47人  無法定义

为了试验mysql连接数与并发数的最大连接数,从500、1000、1500到2000逐步压测,并观察cpu与时延,以确定单台主机所配置的合理连接数范围。

准备

CREATE TABLE `t_order` (
  `order_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `status` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`order_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

CREATE TABLE `t_order_item` (
  `order_item_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `order_id` bigint(20) DEFAULT NULL,
  `user_id` int(11) NOT NULL,
  `status` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`order_item_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

方案

# 插入订单
INSERT INTO t_order(order_id,user_id,status)
values(${no},123456,'INSERT_TEST');
# 插入详情
INSERT INTO t_order_item(order_item_id,order_id,user_id,status)
values(${no},${no},123456,'INSERT_TEST');
# 查询
SELECT * FROM t_order t where order_id = ${no};
show variables like '%max_connections%';
set global max_connections=500;

流程

500连接数,500并发

1000连接数,1000并发

1500连接数,1500并发

2000连接数,2000并发

结论

连接数 并发数 %cpu 吞吐 平均(ms) 最小(ms) 最大(ms) 90%(ms) 95%(ms) 99%(ms)
500 500 387.5 10464.19 36.76 0 3468 50 64 81
1000 1000 628.8 15217.46 52.47 0 6633 54 69 131
1500 1500 775.6 16993.32 71.12 0 8423 55 67 100
2000 2000 902.4 15358.15 108.86 0 11159 67 164 297
上一篇 下一篇

猜你喜欢

热点阅读