安装Xcache缓存加速php及ab压力测试结果

XCache 是一个又快又稳定的 PHP opcode 缓存器. 经过良好的测试并在大流量/高负载的生产机器上稳定运行. 经过(在 linux 上)测试并支持所有现行 PHP 分支的最新发布版本, 如 PHP_5_1 PHP_5_2 PHP_5_3 PHP_5_4. 并完美支持线程安全/Windows. 与同类 opcode 缓存器相比更胜一筹, 比如能够快速跟进 PHP 版本.


我的php为5.6.6版本,所以需要安装xcache3.2.0   

官网下载:http://xcache.lighttpd.net/

tar zxvf xcache-3.2.0.tar.gz
cd xcache-3.2.0
 /usr/local/php/bin/phpize  
 ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 
# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/

安装完成后会在上面的路径下生成xcache.so 文件;

php.ini文件加入xcache代码段(原文件为/usr/local/src/xcache-3.2.0/xcache.ini)

# vi /usr/local/php/etc/php.ini 
[xcache-common]
extension = xcache.so
 
[xcache.admin]
xcache.admin.enable_auth = On 
xcache.admin.user = "xcache"
xcache.admin.pass = ""

[xcache]
xcache.shm_scheme ="mmap"
xcache.size=60M
xcache.count =1
xcache.slots =8K
xcache.ttl=0
xcache.gc_interval =0
xcache.var_size=4M
xcache.var_count =1
xcache.var_slots =8K
xcache.var_ttl=0
xcache.var_maxttl=0
xcache.var_gc_interval =300
xcache.test =Off
xcache.readonly_protection = On
xcache.mmap_path ="/tmp/xcache"
xcache.coredump_directory =""
xcache.cacher =On
xcache.stat=On
xcache.optimizer =Off
[xcache.coverager]
xcache.coverager =On
xcache.coveragedump_directory =""

保存退出后,重启apache,php -v 查看是否有xcache信息;

# /usr/local/php/bin/php -v
PHP 5.6.6 (cli) (built: Jun 29 2015 17:23:08)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with XCache v3.2.0, Copyright (c) 2005-2014, by mOo
    with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo

或phpinfo.php 浏览器中查看;


xcache状态查询:

创建一个缓存文件:touch /tmp/xcache

拷贝xcache3.2.0目录下htdocs目录到你自己的网站目录下,自定义目录名为xcache;

# cp -r htdocs/ /data/www/blog/xcache/

生成md5密码,复制密码拷贝到刚才php.ini文件xcache.admin.pass="" 引号中。

# echo -n ‘123456‘ |md5sum

e10adc3949ba59abbe56e057f20f883e

在浏览器访问 www.star.com/xcache/,弹出认证框输入用户名和密码访问;

ab压力测试进行对比:未安装xcache与安装xcache

使用DELL R420真机(使用discuz论坛首页测试)

在另一台机器上,使用ab压力测试;未安装xcache,3000次并发为118; 3万次并发为74-94之间;

[[email protected] ~]# ab -n 3000 -c 100 www.yong.com/forum.php
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Server Software:        Apache
Server Hostname:        www.yong.com
Server Port:            80
Document Path:          /forum.php
Document Length:        13222 bytes

Concurrency Level:      100
Time taken for tests:   25.247 seconds
Complete requests:      3000
Failed requests:        0
Write errors:           0
Total transferred:      42018000 bytes
HTML transferred:       39666000 bytes
Requests per second:    118.82 [#/sec] (mean)  #每秒处理的请求数
Time per request:       841.579 [ms] (mean)
Time per request:       8.416 [ms] (mean, across all concurrent requests)
Transfer rate:          1625.25 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    4   9.0      2      85
Processing:    66  827 441.1    967    2003
Waiting:       55  812 437.8    953    1992
Total:         68  831 442.2    970    2031
Percentage of the requests served within a certain time (ms)
  50%    970
  66%   1085
  75%   1147
  80%   1187
  90%   1295
  95%   1411
  98%   1680
  99%   1791
 100%   2031 (longest request)

可以查看日志记录也是3000条

[[email protected] logs]# cat yong.com-access_log_20150820.log|wc -l
3000

请求为3万次,测试结果如下:

[[email protected] ~]# ab -n 30000 -c 100 www.yong.com/forum.php 
Server Software:        Apache
Server Hostname:        www.yong.com
Server Port:            80
Document Path:          /forum.php
Document Length:        13222 bytes

Concurrency Level:      100
Time taken for tests:   402.065 seconds
Complete requests:      30000
Failed requests:        2
   (Connect: 0, Receive: 0, Length: 2, Exceptions: 0)
Write errors:           0
Total transferred:      420614188 bytes
HTML transferred:       397069884 bytes
Requests per second:    74.61 [#/sec] (mean)
Time per request:       1340.216 [ms] (mean)
Time per request:       13.402 [ms] (mean, across all concurrent requests)
Transfer rate:          1021.62 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1  170 639.2      4    7553
Processing:    60 1161 1108.3   1037    9234
Waiting:       54  911 534.1    975    7633
Total:         63 1331 1406.5   1068   12650
Percentage of the requests served within a certain time (ms)
  50%   1068
  66%   1208
  75%   1323
  80%   1482
  90%   2672
  95%   4181
  98%   6083
  99%   7630
 100%  12650 (longest request)

系统负载,最高达到88

开启xcache缓存后,3000次请求并发为368;3万次请求并发为103;系统负载最高只有2-4;

[[email protected] ~]# ab -n 3000 -c 100 http://www.yong.com/forum.php
Server Software:        Apache 
Server Hostname:        www.yong.com
Server Port:            80
Document Path:          /forum.php
Document Length:        12579 bytes

Concurrency Level:      100
Time taken for tests:   8.132 seconds
Complete requests:      3000
Failed requests:        8
   (Connect: 0, Receive: 0, Length: 8, Exceptions: 0)
Total transferred:      39787499 bytes
HTML transferred:       37732203 bytes
Requests per second:    368.90 [#/sec] (mean)
Time per request:       271.079 [ms] (mean)
Time per request:       2.711 [ms] (mean, across all concurrent requests)
Transfer rate:          4777.81 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1   36  29.8     27     141
Processing:    27  230 112.0    222     919
Waiting:       17  196 104.1    178     864
Total:         31  266 107.4    252     951
Percentage of the requests served within a certain time (ms)
  50%    252
  66%    298
  75%    333
  80%    352
  90%    398
  95%    452
  98%    518
  99%    592
 100%    951 (longest request)

请求为3万次,测试结果如下:

[[email protected] ~]# ab -n 30000 -c 100 http://www.yong.com/forum.php
Server Software:        Apache 
Server Hostname:        www.yong.com
Server Port:            80
Document Path:          /forum.php
Document Length:        13233 bytes

Concurrency Level:      100
Time taken for tests:   290.761 seconds
Complete requests:      30000
Failed requests:        29963
   (Connect: 0, Receive: 0, Length: 29963, Exceptions: 0)
Total transferred:      397977862 bytes
HTML transferred:       377424199 bytes
Requests per second:    103.18 [#/sec] (mean)
Time per request:       969.202 [ms] (mean)
Time per request:       9.692 [ms] (mean, across all concurrent requests)
Transfer rate:          1336.67 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1  273 830.2      7    5700
Processing:    18  693 1404.2    249    7851
Waiting:       14  366 547.2    212    5480
Total:         19  967 2080.8    276   12416
Percentage of the requests served within a certain time (ms)
  50%    276
  66%    382
  75%    480
  80%    567
  90%   2453
  95%   6768
  98%   9107
  99%   9879
 100%  12416 (longest request)

每次ab压力测试的结果都不太准确,在虚拟机测试结果更不靠谱。特意找的真机测试,除了负载较高,内存使用竟然没太大变化;只能做参考用;

时间: 2024-12-18 09:41:06

安装Xcache缓存加速php及ab压力测试结果的相关文章

WDCP,LNMP安装PHP缓存加速扩展eAccelerator,xcache和memcached

VPS主机性能配置如果太差,则在运行Wordpress博客和Discuz! 论坛等高消耗程序时能够明显感觉出VPS有些吃力.另外,即使VPS主机的CPU.内存.硬盘I/O等性能足够好,但是在面对大流量时则有可能导致PHP执行效率降低,网页打开速度变慢等不正常的情况. 为了能够在低配置的VPS主机上Web也能跑出流畅的感觉和在面对流量高峰时服务器也能从容应对大量的应该访问请求,我们一般会给PHP安装上几点缓存加速扩展:eAccelerator,xcache和memcached,优化动态内容缓存,提

php-xcache编译安装,及ab压力测试

[[email protected] local]# tar -xf xcache-3.2.0.tar.bz2 [[email protected] xcache-3.2.0]# man -M /usr/local/php/php/man phpize 查看帮助文档 [[email protected] xcache-3.2.0]# /usr/local/php/bin/phpize [[email protected] xcache-3.2.0]# man -M /usr/local/php/

ASP.NET 页面缓存OutputCache用法实例(附ab压力测试对比图)

本文主要介绍Web窗体页面中的使用方法,MVC中使用方法,大家自行百度. 一.简单一行指令即可实现 <%@ OutputCache VaryByParam="none" Duration="300" %> 这样整个页面就被缓存了,由于我是首页进行的缓存,没有任何参数所以VaryByParam值设置为none,如果希望通过指定的参数来缓存内容可以设置"id;classid"这种形式,或者干脆就用"*",通过所有参数来

超级web服务器yum 安装apache+源码编译tomcat+awstat+phpmadin+mysql+php+AB压力测试

实验环境: 两台机器:Centos6.4 机器一: 192.168.56.10  安装httpd  php   等整合 机器二: 192.168.56.11 安装 mysql ======================================================================================== (iptables -t nat -I PREROUTING -d 外IP -p tcp -m tcp --dport 端口 -j DNAT --

apache ab压力测试报错apr_socket_recv

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected] ~]# ab -n 100000 -c 1000 http://192.168.2.170/index.htmlThis is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Ada

AB压力测试(Windows)

1.Apache服务器安装 链接: http://jingyan.baidu.com/article/29697b912f6539ab20de3cf8.html 2.AB压力测试帮助 http://wangshuaibo.iteye.com/blog/935454 3.帮助文档 ① Apache报ServerRoot must be a valid directory 解决方法:http://jingyan.baidu.com/article/915fc41491c68751384b2040.h

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) 今天用apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected]~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech

4分钟apache自带ab压力测试工具使用: 2015.10.4

2015.10.44分钟apache自带ab压力测试工具使用:win8.1 wampserver2.5 -Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b 可以参考一下部分讲解有图,我就是打开cmd窗口,进入apache的安装目录(ab一般是apache自带测试工具,所以然后就可以执行需要测试的命令就好了),我的在F:\wamp\bin\apach\apache2.4.9\bin目录下:两种执行方式,1.进入上面说的目录后执行以下命令,如 .\ab -n5000 -

apache优化之防盗链,日志拆分,ab压力测试

Apache调优之apache防盗链.日志拆分和ab压力测试 1.apache防盗链 盗链,全称是盗取链接,假如我们的网站有很多好看的图片,别人可以查看我们网站图片的链接,然后应用在他的网站上,这样的话,去访问他的网站,实际上消耗的是我们的流量(因为实际链接在我们这里),这样我们就不得不去配置防盗链,使得别人不能复制我们图片的链接 要实现防盗链,我们就必须先理解盗链的实现原理,提到防盗链的实现原理就不得不从HTTP协议说起,在HTTP协议中,有一个表头字段叫referer,采用URL的格式来表示