PHP使用Apache中的ab测试网站的压力性能及mpm介绍
2024-10-19 00:31:44
打开Apache安装的bin目录
shift+鼠标右键
复制粘贴以下代码->回车
ab -n 1000 -c 100 http://localhost/test.php
上例表示总共访问http://localhost/test.php这个脚本1000次,100并发(模拟100个用户同时访问)。
Server Software: Apache/2.4.4 #apache版本号
Server Hostname: localhost
Server Port: 80 Document Path: /test/index.php
Document Length: 5 bytes ConcurrencyLevel: 100
Time taken fortests: 54.111 seconds #访问的总时间(秒)
Completerequests: 10000 #访问的总次数
Failed requests: 0
Write errors: 0
Totaltransferred: 2060000 bytes
HTMLtransferred: 50000 bytes
Requests persecond: 184.80 [#/sec] (mean) #每秒访问多少次
Time perrequest: 541.111 [ms] (mean) #这么多人(100)访问一次的时间
Time perrequest: 5.411 [ms] (mean, acrossall concurrent requests) #一个人访问一次花费的时间
Transfer rate: 37.18 [Kbytes/sec] received
ab常用参数的介绍:
-n :总共的请求执行数,缺省是1; -c: 并发数,缺省是1; -t:测试所进行的总时间,秒为单位,缺省50000s -p:POST时的数据文件 -w: 以HTML表的格式输出结果
mpm介绍
mpm是apache自带的,可以用它来测试网站的并发量有多大和某个页面的访问时间。Mpm为多路处理模块,即apache采用怎么样的方式来处理并发,主要有三种方式
1、 perfork 预处理进程方式(用进程服务) 2、 worker 工作模式(用进程下的线程服务) 3、 winnt这个一般是windos 下采用的。(针对windows)
修改Apache默认并发配置
1、 确定当前 apache是mpm模式,CMD下进放到apache的bin目录输入指令httpd –l 会出现以下结果,就可知道它用的是什么模式
Compiledin modules:
core.c
mod_win32.c
mpm_winnt.c 这是为winnt模式
http_core.c
mod_so.c
2、修改httpd-mpm.conf文件,因为从上面可以看到,我的apache用的是winnt模式,所以在该文件下找到对应的winnt_module模块,修改参数,原先为150,我们把它修改成1000
<IfModulempm_winnt_module>
ThreadsPerChild 1000
MaxConnectionsPerChild 0
</IfModule>
同理,如果是其它模式,则在httpd-mpm.conf中修改对应的地方即可。如下
<IfModule mpm_prefork_module>
StartServers 5 #开始启动的进程
MinSpareServers 5 #最小准备进程
MaxSpareServers 10 #最大空闲进程
MaxRequestWorkers 1000 #最大并发数
MaxConnectionsPerChild 0
</IfModule>
3、重启Apache服务器
参考资料:
http://blog.csdn.net/zhangzmb/article/details/51884011
http://blog.csdn.net/aoyoo111/article/details/30734527
最新文章
- Phonegap之ios对iPhone6和Plus的闪屏适配 -- xmTan
- !!常见的上穿突破M20方式——突破还是试探的判断
- 深入理解Java虚拟机 - 虚拟机内存划分
- Mysql Partition 理论知识总结
- 新浪微博授权时出现";关注 *** 的微博";
- SSM所需的jar
- Visual Studio 2017 单独启动MSDN帮助(Microsoft Help Viewer)的方法
- web端本地与服务端时间校验
- [Swift]LeetCode98. 验证二叉搜索树 | Validate Binary Search Tree
- Educational Codeforces Round 62 (Rated for Div. 2) Solution
- Elasticsearch-6.7.0系列(四)Metricbeat仪表盘。本身无端口,依赖kibana
- HTML5 自定义属性
- new和malloc的用法和区别
- 【MongoDB-MongoVUE图像管理工具】
- 【论文笔记】Social Role-Aware Emotion Contagion in Image Social Networks
- DokuWiki
- NIN (Network In Network)
- php连接sql2005
- 【转】社区O2O的增量与存量,机会在哪?
- MySQL统计数据库大小