php xcache set,安装xcache,为php加速

本文详细介绍了如何通过安装和配置xcache来加速PHP应用。首先,进行压力测试以评估基准性能,然后下载并编译安装xcache。安装完成后,更新配置文件并再次进行压力测试,结果显示性能显著提升,特别是在处理高并发请求时。
摘要由CSDN通过智能技术生成

***********安装xcache,为php加速*******************

unzip -o PHPMyAdmin-4.0.5-all-languages.zip

mv PHPMyAdmin-4.0.5-all-languages /usr/local/apache/htdocs/pma

1,压力测试:

ulimit -n 3000

ab -c 100 -n 2000 http://10.10.37.138/pma/index.php 十个并发,发两千个请求

[root@localhost local]# ulimit -n 3000

[root@localhost local]# ab -c 100 -n 2000 http://10.10.37.138/pma/index.php

This is ApacheBench, Version 2.3

Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/

Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.10.37.138 (be patient)

Completed 200 requests

Completed 400 requests

Completed 600 requests

Completed 800 requests

Completed 1000 requests

Completed 1200 requests

Completed 1400 requests

Completed 1600 requests

Completed 1800 requests

Completed 2000 requests

Finished 2000 requests

Server Software:        Apache/2.4.9服务器软件版本

Server Hostname:        10.10.37.138请求的服务器地址

Server Port:            80服务器端口

Document Path:          /pma/index.php

Document Length:        7794 bytesURL的大小

Concurrency Level:      100并发请求

Time taken for tests:   103.874 seconds整个测试经过的时长

Complete requests:      2000一共2000的请求

Failed requests:        0

Total transferred:      17925162 bytes包含首部和数据

HTML transferred:       15588000 bytes总共传输的数据

Requests per second:    19.25 [#/sec] (mean)每秒钟完成的请求数

Time per request:       5193.681 [ms] (mean)每一批(100个)请求需要的时间

Time per request:       51.937 [ms] (mean, across all concurrent requests)每一个请求消耗的时间

Transfer rate:          168.52 [Kbytes/sec] received传输速率

Connection Times (ms)连接时间

min  mean[+/-sd] median   max

Connect:        0   11  58.9      0     497连接建立

Processing:  2445 5139 1298.0   4850   17286请求处理

Waiting:     2445 5111 1303.1   4820   17285等待数据从磁盘加载完成并相应

Total:       2445 5150 1301.4   4858   17286

Percentage of the requests served within a certain time (ms)

50%   4858

66%   5165

75%   5410

80%   5590

90%   6274

95%   7209

98%   9036

99%  11075

100%  17286 (longest request)

sync

2,下载xcache-3.1.2.tar.bz2百度搜索即可

解压解包并编译安装

[root@localhost php]# man -M man/ phpize

/usr/local/php/bin/phpize 编译第三方扩展是都需要执行

./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config

make && make install

安装结束后会出现如下信息:

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

3,配置:

[root@localhost xcache-3.1.2]# mkdir /etc/php.d

[root@localhost xcache-3.1.2]# cp xcache.ini /etc/php.d/

[root@localhost xcache-3.1.2]# vi /etc/php.d/xcache.ini

extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

4,再做压力测试:

http://10.10.37.138/pma/index.php 刷新几次生成缓存

再执行测试

ab -c 100 -n 2000 http://10.10.37.138/pma/index.php

Requests per second:    80.13 [#/sec] (mean)

Time per request:       1248.033 [ms] (mean)

Time per request:       12.480 [ms] (mean, across all concurrent requests)

安装xcache之前的速度

Requests per second:    19.25 [#/sec] (mean)

Time per request:       5193.681 [ms] (mean)

Time per request:       51.937 [ms] (mean, across all concurrent requests)

速度上能快三倍多

Requests per second:    21.97 [#/sec] (mean)

Time per request:       4552.375 [ms] (mean)

Time per request:       45.524 [ms] (mean, across all concurrent requests)

适用于读的多,写的少的服务器类型

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值