首页 / PHP / 53、PHP启用xcache加速
53、PHP启用xcache加速
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了53、PHP启用xcache加速,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4246字,纯文字阅读大概需要7分钟。
内容图文
![53、PHP启用xcache加速](/upload/InfoBanner/zyjiaocheng/846/955c4782ba9e4e9ba468316a6e7a4e3a.jpg)
资源限定
软限制:可以超出的限制,但仅能超出一定时长
硬限制:绝对不能超出的限制
ulimit:只能修改软限制
-n [N]:显示或限制能打开的最大的文件句柄数,
-u [N]:所能够打开的最大进程数
如果修改硬限制
/etc/security/limits.conf,扩展配置etc/security/limits.d/*.conf
对谁进行限定 类型 要限定的选项 值
apache hard nofile65535
apache hard nproc30000
ab工具的初步使用
-c 模拟的并发数
-n 模拟的总请求数
一般并发数应该小于等于请求数
ulimit -n 3000
ab -c 100 -n 10000 http://192.168.130.65/pma/index.php
启动加速前
[root@localhost ~]# ab -c 10 -n 1000 http://192.168.130.65/pma/index.php
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.130.65 (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.37
Server Hostname: 192.168.130.65
Server Port: 80
Document Path: /pma/index.php
Document Length: 14323 bytes
Concurrency Level: 10
Time taken for tests: 19.420 seconds
Complete requests: 1000
Failed requests: 947
(Connect: 0, Receive: 0, Length: 947, Exceptions: 0)
Total transferred: 15841640 bytes
HTML transferred: 14321640 bytes
Requests per second: 51.49 [#/sec] (mean)
Time per request: 194.201 [ms] (mean)
Time per request: 19.420 [ms] (mean, across all concurrent requests)
Transfer rate: 796.62 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.2 0 7
Processing: 105 192 93.3 153 786
Waiting: 98 185 92.7 145 778
Total: 105 192 93.3 153 786
Percentage of the requests served within a certain time (ms)
50% 153
66% 193
75% 227
80% 262
90% 337
95% 373
98% 437
99% 522
100% 786 (longest request)
[root@localhost ~]#
1、安装
tar xf 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 && make install
安装结束时,会出现类似如下行:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
2、编辑php.ini,整合php和xcache:
mkdir /etc/php.d
cp xcache.ini /etc/php.d
vim /etc/php.d/xcache.ini
extension = /usr/local/php/lib/php/extensions/no-debug-zts-20131226/xcache.so
启动加速后
[root@localhost xcache-3.2.0]# ab -c 10 -n 1000 http://192.168.130.65/pma/index.php
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 192.168.130.65 (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.37
Server Hostname: 192.168.130.65
Server Port: 80
Document Path: /pma/index.php
Document Length: 14322 bytes
Concurrency Level: 10
Time taken for tests: 6.322 seconds
Complete requests: 1000
Failed requests: 871
(Connect: 0, Receive: 0, Length: 871, Exceptions: 0)
Total transferred: 15842084 bytes
HTML transferred: 14322084 bytes
Requests per second: 158.17 [#/sec] (mean)
Time per request: 63.225 [ms] (mean)
Time per request: 6.322 [ms] (mean, across all concurrent requests)
Transfer rate: 2446.95 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 0
Processing: 36 63 55.1 50 670
Waiting: 34 60 54.8 47 670
Total: 36 63 55.1 50 670
Percentage of the requests served within a certain time (ms)
50% 50
66% 56
75% 62
80% 65
90% 78
95% 98
98% 229
99% 426
100% 670 (longest request)
[root@localhost xcache-3.2.0]#
内容总结
以上是互联网集市为您收集整理的53、PHP启用xcache加速全部内容,希望文章能够帮你解决53、PHP启用xcache加速所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。