LAMP之AMP分离+XCache加速(5)

压力测试

[root@client ~]# ab -n 3000 -c 100 httpd://www.discuz.com/index.php 省略部分内容…… Server Software: Apache/2.4.10 Server Hostname: bbs.discuz.com Server Port: 80 Document Path: /index.php Document Length: 7691 bytes Concurrency Level: 100 Time taken for tests: 58.782 seconds Complete requests: 3000 Failed requests: 2137 (Connect:0, Receive: 0, Length: 2137, Exceptions: 0) Write errors: 0 Non-2xx responses: 29 Total transferred: 23679924 bytes HTML transferred: 22723414 bytes Requests per second: 51.04 [#/sec] (mean) #每秒可以处理请求 Time per request: 1959.391 [ms] (mean) Time per request: 19.594 [ms] (mean, across all concurrentrequests) Transfer rate: 393.40 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 2 10.2 0 135 Processing: 142 1926 1621.3 1355 31212 Waiting: 141 1924 1620.6 1354 31212 Total: 195 1928 1620.6 1356 31212 Percentage of the requests served within a certaintime (ms) 50% 1356 66% 1717 75% 2312 80% 2482 90% 2945 95% 4149 98% 6231 99% 9875 100% 31212 (longest request) 部署 xcache php 加速

编译安装Xcache

tar xf xcache-3.2.0.tar.bz2 cd xcache-3.2.0 /usr/local/php5/bin/phpize ./configure --enable-xcache--with-php-config=/usr/local/php5/bin/php-config make && make install

安装结束会出现如下行

Installing shared extensions:    /usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/

整合php和xcache,将XCache配置文件复制到php.d目录下,使php可以读取XCache配置文件

[root@bbs-01 xcache-3.2.0]# mkdir /etc/php.d [root@bbs-01 xcache-3.2.0]# cp xcache.ini/etc/php.d/

接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行

zend_extension =/usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/xcache.so

设置完成之后,重启php-fpm服务。

在bbs网页目录准备php测试页面,访问如果出现Xcache的内容说明Xcache安装成功

LAMP之AMP分离+XCache加速

在次进行压力测试

[root@client ~]# ab -n 3000 -c 100 省略部分内容………… Server Software: Apache/2.4.10 Server Hostname: bbs.discuz.com Server Port: 80 Document Path: /index.php Document Length: 7687 bytes Concurrency Level: 100 Time taken for tests: 9.983 seconds Complete requests: 3000 Failed requests: 0 Write errors: 0 Total transferred: 24031128 bytes HTML transferred: 23061000 bytes Requests per second: 300.51 [#/sec] (mean) Time per request: 332.762 [ms] (mean) Time per request: 3.328 [ms] (mean, across all concurrentrequests) Transfer rate: 2350.82 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 1 3.9 0 25 Processing: 31 327 45.2 328 701 Waiting: 31 327 45.2 327 701 Total: 42 328 43.4 328 701 Percentage of the requests served within a certaintime (ms) 50% 328 66% 339 75% 346 80% 354 90% 378 95% 391 98% 417 99% 428 100% 701 (longest request)

通过对比安装Xcache前后的压力测试结果,可以看出处理的请求数由每秒处理50个请求提升到了300个,当然由于是本机进行测试,没有考虑带宽的因素,所以性能稍高。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d747b2aef52016bf2bb1fdb2869d1336.html