阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

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

173次阅读
没有评论

共计 8160 个字符,预计需要花费 21 分钟才能阅读完成。

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

LAMP 平台安装 Xcache 和 Memcached 加速网站运行  http://www.linuxidc.com/Linux/2015-06/118835.htm 

LAMP 之 AMP 分离 +XCache 加速  http://www.linuxidc.com/Linux/2015-06/118834.htm

LAMP+Xcache 环境搭建  http://www.linuxidc.com/Linux/2014-05/101087.htm

我的 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 缓存加速 php 及 ab 压力测试结果

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/,弹出认证框输入用户名和密码访问;

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

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

更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2015-08/122108p2.htm

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

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

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

[root@localhost ~]# ab -n 3000 -c 100 www.linuxidc.com/forum.php

This is ApacheBench, Version 2.3 <$Revision: 655654 $>

Server Software:        Apache

Server Hostname:        www.linuxidc.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 条

[root@localhost logs]# cat linuxidc.com-access_log_20150820.log|wc -l

3000

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

[root@localhost ~]# ab -n 30000 -c 100 www.linuxidc.com/forum.php

Server Software:        Apache

Server Hostname:        www.linuxidc.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 缓存加速 php 及 ab 压力测试结果

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

[root@localhost ~]# ab -n 3000 -c 100 http://www.linuxidc.com/forum.php

Server Software:        Apache

Server Hostname:        www.linuxidc.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 万次,测试结果如下:

[root@localhost ~]# ab -n 30000 -c 100 http://www.linuxidc.com/forum.php

Server Software:        Apache

Server Hostname:        www.linuxidc.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 压力测试的结果都不太准确,在虚拟机测试结果更不靠谱。特意找的真机测试,除了负载较高,内存使用竟然没太大变化;只能做参考用;

本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-08/122108.htm

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

LAMP 平台安装 Xcache 和 Memcached 加速网站运行  http://www.linuxidc.com/Linux/2015-06/118835.htm 

LAMP 之 AMP 分离 +XCache 加速  http://www.linuxidc.com/Linux/2015-06/118834.htm

LAMP+Xcache 环境搭建  http://www.linuxidc.com/Linux/2014-05/101087.htm

我的 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 缓存加速 php 及 ab 压力测试结果

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/,弹出认证框输入用户名和密码访问;

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

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

更多详情见请继续阅读下一页的精彩内容:http://www.linuxidc.com/Linux/2015-08/122108p2.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计8160字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中