S1:来点必须的理论知识
S3:开始压力测试吧:
[root@localhost ~]# /usr/local/apache2/bin/ab -c 500 -n 5000 "http://localhost/user/login.php"
Requests per second: 143.69 [#/sec] (mean) // 平均每秒的请求数
Percentage of the requests served within a certain time (ms) // x请求在y秒内完成
下图是--- 1000个并发数 +50000个请求 处理时主机的性能:
/usr/local/apache2/bin/ab: Cannot use concurrency level greater than total number of requests
我的理解是: 这丫说:总并发数不能大于总请求数
Q:什么是并发:
A:在操作系统中,是指一个时间段中有几个程序都处于已启动运行到运行完毕之间,且这几个程序都是在同一个处理机上运行,担任一个时刻点上只有一个程序在处理机上运行。
如果看不懂上面关于并发的解释,请看下图:
Q:并发连接数的增大意味着对系统内存资源的消耗? A:以每个并发连接表项占用300B计算,1000个并发连接将占用300B×1000×8bit/B≈2.3Mb内存空间,10000个并发连接将占用 23Mb内存空间,100000个并发连接将占用230Mb内存空间,而如果真的试图实现1000000个并发连接的话那么,就需要提供 2.24Gb内存空间!
S2.再看看未测试前的机器性能
[root@localhost ~]# top 显示如下: top - 11:45:17 up 151 days, 18:27, 2 users, load average: 0.02, 8.13, 11.01 Mem: 4037096k total, 1987016k used, 2050080k free, 195340k buffers Swap: 2031608k total, 0k used, 2031608k free, 1506700k cached 这上面主要看load average负载, 详细解释请看 http://wenku.baidu.com/view/19aa7cdc5022aaea998f0f1f.html
S3:开始压力测试吧:
[root@localhost ~]# /usr/local/apache2/bin/ab -c 500 -n 5000 "http://localhost/user/login.php"
![](https://img-my.csdn.net/uploads/201205/07/1336396965_8176.png)
Concurrency Level: 1000 // 总并发数
Complete requests: 50000 // 总请求数Requests per second: 143.69 [#/sec] (mean) // 平均每秒的请求数
Percentage of the requests served within a certain time (ms) // x请求在y秒内完成
下图是--- 1000个并发数 +50000个请求 处理时主机的性能:
![](https://img-my.csdn.net/uploads/201205/07/1336397035_2354.png)
会出现的一些问题:
[root@localhost ~]# /usr/local/apache2/bin/ab -c 5 -n 2 "http://localhost/user/login.php";/usr/local/apache2/bin/ab: Cannot use concurrency level greater than total number of requests
我的理解是: 这丫说:总并发数不能大于总请求数