013-LAMP_enchance concurrency
2016-01-21 11:53
459 查看
013-LAMP_enchance concurrency
测试静态页面并发访问
This is ApacheBench, Version 2.3 <$Revision: 1706008 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.200.137 (be patient) Server Software: Apache/2.4.6 Server Hostname: 192.168.200.137 Server Port: 80 Document Path: /index.html Document Length: 21 bytes Concurrency Level: 100 Time taken for tests: 0.165 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 281000 bytes HTML transferred: 21000 bytes Requests per second: 6071.98 [#/sec] (mean) Time per request: 16.469 [ms] (mean) Time per request: 0.165 [ms] (mean, across all concurrent requests) Transfer rate: 1666.24 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 2 2.5 1 12 Processing: 5 14 2.6 14 23 Waiting: 5 14 2.7 13 22 Total: 7 15 2.8 15 23 Percentage of the requests served within a certain time (ms) 50% 15 66% 16 75% 17 80% 18 90% 20 95% 21 98% 21 99% 23 100% 23 (longest request)
测试动态资源并发访问
This is ApacheBench, Version 2.3 <$Revision: 1706008 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.200.137 (be patient) Server Software: Apache/2.4.6 Server Hostname: 192.168.200.137 Server Port: 80 Document Path: /index.php Document Length: 7 bytes Concurrency Level: 100 Time taken for tests: 0.799 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 179000 bytes HTML transferred: 7000 bytes Requests per second: 1252.13 [#/sec] (mean) Time per request: 79.864 [ms] (mean) Time per request: 0.799 [ms] (mean, across all concurrent requests) Transfer rate: 218.88 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.6 0 5 Processing: 7 76 15.9 75 122 Waiting: 7 76 15.9 75 122 Total: 8 76 15.8 76 122 Percentage of the requests served within a certain time (ms) 50% 76 66% 81 75% 85 80% 88 90% 98 95% 102 98% 105 99% 110 100% 122 (longest request)
apache benchmark fields explanation
Benchmarking 192.168.200.137 (be patient) #表示正在向192.168.200.137测试 Server Software: Apache/2.4.6 #表示web server的类型 Server Hostname: 192.168.200.137 #表示server的IP Server Port: 80 #表示测试的端口 Document Path: /index.php #表示资源的路径 Document Length: 7 bytes #表示资源的大小 Concurrency Level: 100 #表示并发级别,即每秒100个请求 Time taken for tests: 0.799 seconds #表示测试的时长 Complete requests: 1000 #表示请求的数量,一共1000个 Failed requests: 0 #表示失败的请求个数 Total transferred: 179000 bytes #表示总传输字节,这里包括各种header等 HTML transferred: 7000 bytes #表示仅仅是资源的总大小 Requests per second: 1252.13 [#/sec] (mean) #表示平均每秒的可以处理的请求数量 Time per request: 79.864 [ms] (mean) #表示平均每次并发的处理时长 Time per request: 0.799 [ms] (mean, across all concurrent requests) #表示平均每条请求的处理时长 Transfer rate: 218.88 [Kbytes/sec] received #表示传输速率 Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.6 0 5 #表示连接时长 Processing: 7 76 15.9 75 122 #表示处理时长 Waiting: 7 76 15.9 75 122 #表示等待时长 Total: 8 76 15.8 76 122 #表示总的消耗时长 Percentage of the requests served within a certain time (ms) #表示#ms响应的百分比 50% 76 66% 81 75% 85 80% 88 90% 98 95% 102 98% 105 99% 110 100% 122 (longest request)
从静态及动态测试中可以看出静态页面的响应速度明显比动态资源快!
xchahe
[root@husa php]# yum install php-xcache xcache位于epel源 php-xcache x86_64 3.1.1-1.el7 c5fc epel 72 k
查看xcache生成的各种文件
[root@husa php]# rpm -ql php-xcache /etc/php.d/xcache.ini /usr/lib64/php/modules/xcache.so /usr/share/doc/php-xcache-3.1.1 /usr/share/doc/php-xcache-3.1.1/AUTHORS /usr/share/doc/php-xcache-3.1.1/COPYING /usr/share/doc/php-xcache-3.1.1/ChangeLog /usr/share/doc/php-xcache-3.1.1/README /usr/share/doc/php-xcache-3.1.1/THANKS
xcache配置文件
/etc/php.d/xcache.ini
[xcache.admin] xcache.admin.enable_auth = On #表示是否启用xcache xcache.admin.user = "mOo" #表示xcache的admin的用户名 xcache.admin.pass = "md5 encrypted password" #表示xcache的admin的用户密码 xcache.size = 60M #表示xcache的缓存大小 xcache.ttl = 0 #表示xcache的缓存生命时长,0表示forever
配置xcache生效
直接reload php-fpm[root@husa php.d]# systemctl reload php-fpm
配置xcache之后的动态资源请求结果
[husa@ArchLinux-husa ~]$ ab -n 1000 -c 100 http://192.168.200.137/index.php This is ApacheBench, Version 2.3 <$Revision: 1706008 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 192.168.200.137 (be patient) Completed 100 requests Completed 200 requests Completed 300 requests Completed 400 requests Completed 500 requests Completed 600 requests Completed 700 requests Completed 800 requests Completed 900 requests Completed 1000 requests Finished 1000 requests Server Software: Apache/2.4.6 Server Hostname: 192.168.200.137 Server Port: 80 Document Path: /index.php Document Length: 7 bytes Concurrency Level: 100 Time taken for tests: 0.625 seconds Complete requests: 1000 Failed requests: 0 Total transferred: 179000 bytes HTML transferred: 7000 bytes Requests per second: 1600.62 [#/sec] (mean) Time per request: 62.476 [ms] (mean) Time per request: 0.625 [ms] (mean, across all concurrent requests) Transfer rate: 279.80 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 2.9 0 14 Processing: 15 58 8.4 58 96 Waiting: 15 58 8.4 58 96 Total: 29 59 6.9 59 96 Percentage of the requests served within a certain time (ms) 50% 59 66% 61 75% 63 80% 64 90% 67 95% 70 98% 74 99% 78 100% 96 (longest request)
可以发现总的时长减少了大约0.3毫秒
编译安装xcache
编译安装php扩展1、安装php-devel
[root@husa php.d]# systemctl reload php-fpm
2、下载xcache
[root@husa ~]# ls 99.sh anaconda-ks.cfg a.sh grub.bak linux-3.10.67.tar.xz pma scp.txt service.sh show.sh xcache-3.2.0.tar.bz2 [root@husa ~]# tar xjf xcache-3.2.0.tar.bz2 [root@husa ~]# ls 99.sh a.sh linux-3.10.67.tar.xz scp.txt show.sh xcache-3.2.0.tar.bz2 anaconda-ks.cfg grub.bak pma service.sh xcache-3.2.0
3、在源代码目录中运行phpize命令
phpize - prepare a PHP extension for compiling 这个命令是用来为PHP编译安装扩展的
4、配置编译脚本然后编译安装
/configure --enable-xcache --with-php-config=/usr/bin/php-config [root@husa xcache-3.2.0]# make -j 2 && make install
–enable-xcache表示编译安装之后直接启用xcache,with-php-config表示提供php的配置文件给php-xcache
5、把源代码目录中的xcache.ini配置文件放置到/etc/php.d目录中然后进行相应的配置
[root@husa xcache-3.2.0]# cp xcache.ini /etc/php.d/
6、重载php-fpm
[root@husa php.d]# systemctl reload php-fpm
7、压力测试
注意:本地测试没有考虑带宽,因此要远程测试
相关文章推荐
- 【爱情森林】病毒清除
- 【转】 linux iio子系统
- RabbitMQ 安装
- 并发编程学习:使用读写锁来编写高效率的缓存系统
- “大寒”暖心福利《光明传说》水晶获取攻略·上篇
- Android拨打电话(Intent.ACTION.CALL)
- UITableview代理方法与Viewcontroller分离
- 奇偶排序Odd-even sort
- js console.log打印对像与数组用法详解
- Linux系统中dig命令用法完全罗列
- 7、React中的refs的使用
- Java类与对象===Java变量的作用域
- ZIGBee组网流程
- 64位Ubuntu12.04下安装arm-linux-gdb,以及解决no termcap library found的方法
- dedecms获取当前文章所在栏目URL
- 能够返回运行结果的system函数加强版本号
- (转)MVC3 类型“System.Web.Mvc.ModelClientValidationRule”同时存在
- JSONObject put,accumulate,element的区别
- Web前端攻防
- droWtsaLfohtgneL.58