ab测试工具:
ab -n 500 -c 50 秒杀测试地址
测试商品表结构:
CREATE TABLE tb_good
(
gid
int(11) NOT NULL AUTO_INCREMENT,
gname
varchar(32) DEFAULT NULL,
gcount
int(11) DEFAULT NULL,
PRIMARY KEY (gid
)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='秒杀商品表';
php程序:
商品数量为3,
ab工具的输出:
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking **** (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Finished 500 requests
Server Software: Apache/2.4.37
Server Hostname: ****
Server Port: 80
Document Path: /bingfa/index/test1
Document Length: 18 bytes
Concurrency Level: 50
Time taken for tests: 17.348 seconds
Complete requests: 500
Failed requests: 496
(Connect: 0, Receive: 0, Length: 496, Exceptions: 0)
Total transferred: 106024 bytes
HTML transferred: 6024 bytes
Requests per second: 28.82 [#/sec] (mean)
Time per request: 1734.788 [ms] (mean)
Time per request: 34.696 [ms] (mean, across all concurrent requests)
Transfer rate: 5.97 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 17 49.4 5 263
Processing: 319 1506 1790.6 931 7178
Waiting: 319 1506 1790.6 931 7178
Total: 330 1523 1819.0 938 7410
Percentage of the requests served within a certain time (ms)
50% 938
66% 977
75% 1028
80% 1067
90% 4637
95% 7021
98% 7248
99% 7320
100% 7410 (longest request)
从ab的输出可以看到,成功的请求有4个,但是我的库存只有3个,为什么会出现这样的情况呢