標籤:加速 xcache php
***********安裝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 十個並發,發兩千個請求
[[email protected] local]# ulimit -n 3000
[[email protected] local]# ab -c 100 -n 2000 http://10.10.37.138/pma/index.php
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
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百度搜尋即可
解壓解包並編譯安裝
[[email protected] 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,配置:
[[email protected] xcache-3.1.2]# mkdir /etc/php.d
[[email protected] xcache-3.1.2]# cp xcache.ini /etc/php.d/
[[email protected] 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)
適用於讀的多,寫的少的伺服器類型
本文出自 “linux” 部落格,請務必保留此出處http://loveall.blog.51cto.com/8658573/1877884
編譯安裝lamp-4(安裝xcache,為php加速)