XCache 是套華人所撰寫的 PHP opcode cacher,在速度上的表現真的是讓人驚豔的軟體,網路上應該可以看到不少對它的讚賞
其實早就知道這套軟體,但最終還是因為自己懶,所以一直都沒去安裝。最近心血來潮,才把它裝上去 主機的OS分別有 Windows 和 FreeBSD ,在這邊就先紀錄一下安裝的紀錄。
FreeBSD:
# cd /usr/ports/www/xcache ; make install cleanWindows:
這邊指得是複製到你 php 安裝的 extension 資料夾下。
複製 php_xcache.dll 到 c:php5ext 下 接著把 xcache.ini 的設定,複製到 php.ini 裡。
XCache 的設定:
[xcache-common]
;; 安裝成 zend extension (建議), 一般的格式 "$extension_dir/xcache.so"
;zend_extension = /usr/local/lib/php/extensions/\
;non-debug-non-zts-xxx/xcache.so
; zend_extension_ts = /usr/local/lib/php/extensions/\
;non-debug-zts-xxx/xcache.so
;; Windows 的設法是把 xcache.so 改成 php_xcache.dll
;zend_extension_ts = "D:\Server\php\ext\php_xcache.dll
;; 或者安裝成 extension, 當然要確定你的 extension 資料夾要設定好。
; extension = xcache.so
;; Windows 設法:
; extension = php_xcache.dll
[xcache.admin]
xcache.admin.user = "ib_admin"
; 可以先用 md5 -s (你要的密碼) 來生出下面那串
xcache.admin.pass = 30a968885551f66565bc60efd84be750
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme = "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
; 雖然說可以支援到用 64M,但依我現在的使用狀況,調大太網站就會不能顯示。
; 不知道是不是使用 unstable 版本的關係。
xcache.size = 4M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
; 幾個 CPU 就填幾個幾個上去,官網是不建議把 HT 模擬出來的當成一個 CPU 來算。
xcache.count = 2
; just a hash hints, you can always store count(items) > slots
xcache.slots = 8K
; ttl of the cache item, 0=forever
xcache.ttl = 600
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval = 0
; same as aboves but for variable cache
; 如果沒有用 XCache 的命名變數,這邊可以省略不理它。
xcache.var_size = 2M
xcache.var_count = 1
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 600
xcache.var_maxttl = 3600
xcache.var_gc_interval = 300
xcache.test = Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won’t share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path = "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it’s writable by php (without checking open_basedir)
xcache.coredump_directory = "D:\web\xcache\tmp"
; per request settings
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and
; xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager = On
; ini only settings
; make sure it’s readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = "D:\web\xcache\tmp"
在一台有 1G 記憶體的 Windows 2003 上,xcache.size 只要超過 4M 就會無法正常顯示 …
下面说说配置.
athlonxp 2500+,512M
linux 2.6.17,lighttpd 1.4.11,php 5.1.6-r4(fastcgi only)
测试开始…本次的测试是关于wordpress的.
其文件极其散乱,而且一次 include入php,比较有参考价值.
数据库选用sqlite,减少数据库对检测结果的影响.
首先phpinfo:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.1-rc1, Copyright (c) 2005-2006, by mOo
测试开始,选用http_load.
首先是有xcache:
echo “http://localhost/wordpress/” > urls
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 3.35984 seconds
5019 mean bytes/connection
29.7633 fetches/sec, 149382 bytes/sec
msecs/connect: 0.13715 mean, 0.273 max, 0.085 min
msecs/first-response: 66.8873 mean, 167.985 max, 30.531 min
HTTP response codes:
code 200 — 100
=====
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.28153 seconds
5019 mean bytes/connection
30.4736 fetches/sec, 152947 bytes/sec
msecs/connect: 0.13858 mean, 0.4 max, 0.075 min
msecs/first-response: 130.298 mean, 759.901 max, 30.482 min
HTTP response codes:
code 200 — 100
无xcache:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 10.0079 seconds
5019 mean bytes/connection
9.99214 fetches/sec, 50150.5 bytes/sec
msecs/connect: 0.13365 mean, 0.275 max, 0.084 min
msecs/first-response: 199.817 mean, 341.949 max, 97.539 min
HTTP response codes:
code 200 — 100
==
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 10.1744 seconds
5019 mean bytes/connection
9.82854 fetches/sec, 49329.4 bytes/sec
msecs/connect: 0.13894 mean, 0.414 max, 0.081 min
msecs/first-response: 403.88 mean, 1558.21 max, 100.83 min
HTTP response codes:
code 200 — 100
下面是apc的测试.安装:
sudo emerge dev-php5/pecl-apc
测试:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 4.43893 seconds
5019 mean bytes/connection
22.5279 fetches/sec, 113068 bytes/sec
msecs/connect: 0.14309 mean, 0.312 max, 0.117 min
msecs/first-response: 88.3375 mean, 1144.08 max, 35.72 min
HTTP response codes:
code 200 — 100
===
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.88155 seconds
5019 mean bytes/connection
25.7629 fetches/sec, 129304 bytes/sec
msecs/connect: 0.13987 mean, 0.423 max, 0.084 min
msecs/first-response: 154.125 mean, 1008.84 max, 35.509 min
HTTP response codes:
code 200 — 100
eacc:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 3.44538 seconds
5019 mean bytes/connection
29.0244 fetches/sec, 145673 bytes/sec
msecs/connect: 0.13382 mean, 0.222 max, 0.052 min
msecs/first-response: 68.5373 mean, 498.572 max, 28.028 min
HTTP response codes:
code 200 — 100
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.23513 seconds
5019 mean bytes/connection
30.9107 fetches/sec, 155141 bytes/sec
msecs/connect: 0.13717 mean, 0.403 max, 0.081 min
msecs/first-response: 128.14 mean, 889.398 max, 28.203 min
HTTP response codes:
code 200 — 100
虽然这次测试可能会有一定的不确定因素,
但是总体上还在预料之中.
eacc>xcache>apc>>>>>>啥也没有.
而eacc,xcache的差距很小…
啥都别说了,大家都可以开始准备用xcache了
其實早就知道這套軟體,但最終還是因為自己懶,所以一直都沒去安裝。最近心血來潮,才把它裝上去 主機的OS分別有 Windows 和 FreeBSD ,在這邊就先紀錄一下安裝的紀錄。
FreeBSD:
# cd /usr/ports/www/xcache ; make install cleanWindows:
這邊指得是複製到你 php 安裝的 extension 資料夾下。
複製 php_xcache.dll 到 c:php5ext 下 接著把 xcache.ini 的設定,複製到 php.ini 裡。
XCache 的設定:
[xcache-common]
;; 安裝成 zend extension (建議), 一般的格式 "$extension_dir/xcache.so"
;zend_extension = /usr/local/lib/php/extensions/\
;non-debug-non-zts-xxx/xcache.so
; zend_extension_ts = /usr/local/lib/php/extensions/\
;non-debug-zts-xxx/xcache.so
;; Windows 的設法是把 xcache.so 改成 php_xcache.dll
;zend_extension_ts = "D:\Server\php\ext\php_xcache.dll
;; 或者安裝成 extension, 當然要確定你的 extension 資料夾要設定好。
; extension = xcache.so
;; Windows 設法:
; extension = php_xcache.dll
[xcache.admin]
xcache.admin.user = "ib_admin"
; 可以先用 md5 -s (你要的密碼) 來生出下面那串
xcache.admin.pass = 30a968885551f66565bc60efd84be750
[xcache]
; ini only settings, all the values here is default unless explained
; select low level shm/allocator scheme implemenation
xcache.shm_scheme = "mmap"
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size > 0) and your system mmap allows
; 雖然說可以支援到用 64M,但依我現在的使用狀況,調大太網站就會不能顯示。
; 不知道是不是使用 unstable 版本的關係。
xcache.size = 4M
; set to cpu count (cat /proc/cpuinfo |grep -c processor)
; 幾個 CPU 就填幾個幾個上去,官網是不建議把 HT 模擬出來的當成一個 CPU 來算。
xcache.count = 2
; just a hash hints, you can always store count(items) > slots
xcache.slots = 8K
; ttl of the cache item, 0=forever
xcache.ttl = 600
; interval of gc scanning expired items, 0=no scan, other values is in seconds
xcache.gc_interval = 0
; same as aboves but for variable cache
; 如果沒有用 XCache 的命名變數,這邊可以省略不理它。
xcache.var_size = 2M
xcache.var_count = 1
xcache.var_slots = 8K
; default ttl
xcache.var_ttl = 600
xcache.var_maxttl = 3600
xcache.var_gc_interval = 300
xcache.test = Off
; N/A for /dev/zero
xcache.readonly_protection = Off
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won’t share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path
xcache.mmap_path = "/dev/zero"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it’s writable by php (without checking open_basedir)
xcache.coredump_directory = "D:\web\xcache\tmp"
; per request settings
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and
; xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)
xcache.coverager = On
; ini only settings
; make sure it’s readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On
xcache.coveragedump_directory = "D:\web\xcache\tmp"
在一台有 1G 記憶體的 Windows 2003 上,xcache.size 只要超過 4M 就會無法正常顯示 …
下面说说配置.
athlonxp 2500+,512M
linux 2.6.17,lighttpd 1.4.11,php 5.1.6-r4(fastcgi only)
测试开始…本次的测试是关于wordpress的.
其文件极其散乱,而且一次 include入php,比较有参考价值.
数据库选用sqlite,减少数据库对检测结果的影响.
首先phpinfo:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
with XCache v1.1-rc1, Copyright (c) 2005-2006, by mOo
测试开始,选用http_load.
首先是有xcache:
echo “http://localhost/wordpress/” > urls
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 3.35984 seconds
5019 mean bytes/connection
29.7633 fetches/sec, 149382 bytes/sec
msecs/connect: 0.13715 mean, 0.273 max, 0.085 min
msecs/first-response: 66.8873 mean, 167.985 max, 30.531 min
HTTP response codes:
code 200 — 100
=====
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.28153 seconds
5019 mean bytes/connection
30.4736 fetches/sec, 152947 bytes/sec
msecs/connect: 0.13858 mean, 0.4 max, 0.075 min
msecs/first-response: 130.298 mean, 759.901 max, 30.482 min
HTTP response codes:
code 200 — 100
无xcache:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 10.0079 seconds
5019 mean bytes/connection
9.99214 fetches/sec, 50150.5 bytes/sec
msecs/connect: 0.13365 mean, 0.275 max, 0.084 min
msecs/first-response: 199.817 mean, 341.949 max, 97.539 min
HTTP response codes:
code 200 — 100
==
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 10.1744 seconds
5019 mean bytes/connection
9.82854 fetches/sec, 49329.4 bytes/sec
msecs/connect: 0.13894 mean, 0.414 max, 0.081 min
msecs/first-response: 403.88 mean, 1558.21 max, 100.83 min
HTTP response codes:
code 200 — 100
下面是apc的测试.安装:
sudo emerge dev-php5/pecl-apc
测试:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 4.43893 seconds
5019 mean bytes/connection
22.5279 fetches/sec, 113068 bytes/sec
msecs/connect: 0.14309 mean, 0.312 max, 0.117 min
msecs/first-response: 88.3375 mean, 1144.08 max, 35.72 min
HTTP response codes:
code 200 — 100
===
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.88155 seconds
5019 mean bytes/connection
25.7629 fetches/sec, 129304 bytes/sec
msecs/connect: 0.13987 mean, 0.423 max, 0.084 min
msecs/first-response: 154.125 mean, 1008.84 max, 35.509 min
HTTP response codes:
code 200 — 100
eacc:
./http_load -parallel 2 -fetches 100 urls
100 fetches, 2 max parallel, 501900 bytes, in 3.44538 seconds
5019 mean bytes/connection
29.0244 fetches/sec, 145673 bytes/sec
msecs/connect: 0.13382 mean, 0.222 max, 0.052 min
msecs/first-response: 68.5373 mean, 498.572 max, 28.028 min
HTTP response codes:
code 200 — 100
./http_load -parallel 4 -fetches 100 urls
100 fetches, 4 max parallel, 501900 bytes, in 3.23513 seconds
5019 mean bytes/connection
30.9107 fetches/sec, 155141 bytes/sec
msecs/connect: 0.13717 mean, 0.403 max, 0.081 min
msecs/first-response: 128.14 mean, 889.398 max, 28.203 min
HTTP response codes:
code 200 — 100
虽然这次测试可能会有一定的不确定因素,
但是总体上还在预料之中.
eacc>xcache>apc>>>>>>啥也没有.
而eacc,xcache的差距很小…
啥都别说了,大家都可以开始准备用xcache了
使用memcached进行内存缓存
Unix体验中心──免费的Unix/Linux服务器体验和测试平台













