XCache 是一個(gè)又快又穩(wěn)定的 PHP opcode 緩存器. 經(jīng)過良好的測試并在大流量/高負(fù)載的生產(chǎn)機(jī)器上穩(wěn)定運(yùn)行. 經(jīng)過(在 linux 上)測試并支持所有現(xiàn)行 PHP 分支的最新發(fā)布版本, 如 PHP_5_1 PHP_5_2 PHP_5_3 PHP_5_4. 并完美支持線程安全/Windows. 與同類 opcode 緩存器相比更勝一籌, 比如能夠快速跟進(jìn) PHP 版本.
在潮州等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、成都做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作定制設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站建設(shè),潮州網(wǎng)站建設(shè)費(fèi)用合理。我的php為5.6.6版本,所以需要安裝xcache3.2.0
官網(wǎng)下載: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/安裝完成后會(huì)在上面的路徑下生成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狀態(tài)查詢:
創(chuàng)建一個(gè)緩存文件:touch /tmp/xcache
拷貝xcache3.2.0目錄下htdocs目錄到你自己的網(wǎng)站目錄下,自定義目錄名為xcache;
# cp -r htdocs/ /data/www/blog/xcache/
生成md5密碼,復(fù)制密碼拷貝到剛才php.ini文件xcache.admin.pass="" 引號(hào)中。
# echo -n '123456' |md5sum
e10adc3949ba59abbe56e057f20f883e
在瀏覽器訪問 www.star.com/xcache/,彈出認(rèn)證框輸入用戶名和密碼訪問;
ab壓力測試進(jìn)行對(duì)比:未安裝xcache與安裝xcache
使用DELL R420真機(jī)(使用discuz論壇首頁測試)
在另一臺(tái)機(jī)器上,使用ab壓力測試;未安裝xcache,3000次并發(fā)為118; 3萬次并發(fā)為74-94之間;
[root@localhost ~]# 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) #每秒處理的請求數(shù) 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 yong.com-access_log_20150820.log|wc -l 3000請求為3萬次,測試結(jié)果如下:
[root@localhost ~]# 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)系統(tǒng)負(fù)載,高達(dá)到88
開啟xcache緩存后,3000次請求并發(fā)為368;3萬次請求并發(fā)為103;系統(tǒng)負(fù)載高只有2-4;
[root@localhost ~]# 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萬次,測試結(jié)果如下:
每次ab壓力測試的結(jié)果都不太準(zhǔn)確,在虛擬機(jī)測試結(jié)果更不靠譜。特意找的真機(jī)測試,除了負(fù)載較高,內(nèi)存使用竟然沒太大變化;只能做參考用;
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。