假设我正在使用PHP 5.5操作码缓存,并设置
opcache.memory_consumption=128
如果我在php-fpm中有4个池,那么4个池中的每个池共享128MB的缓存,或者它们是否会为每个池拥有128M的opcache?
如果您对池之间使用的高速缓存如何进行简单测试有任何疑问.
技术很简单.在不同的www-dir上创建2个fpm-pool,例如8081和8082端口以及2个文件index.php和check.php,内容相同:
<?php
echo "<pre>\n";
var_dump(opcache_get_status());
Run Code Online (Sandbox Code Playgroud)
首先重新启动你的php-fpm的服务,然后运行第一个池localhost:8081/index.php,然后localhost:8082/check.php.["scripts"]输出后检查部分.我有下一个结果:
本地主机:8081/index.php文件
["scripts"]=>
array(1) {
["/usr/share/nginx/html/index.php"]=>
array(6) {
["full_path"]=>
string(31) "/usr/share/nginx/html/index.php"
["hits"]=>
int(0)
["memory_consumption"]=>
int(1032)
["last_used"]=>
string(24) "Mon Dec 23 23:38:35 2013"
["last_used_timestamp"]=>
int(1387827515)
["timestamp"]=>
int(1387825100)
}
}
Run Code Online (Sandbox Code Playgroud)
本地主机:8082/check.php
["scripts"]=>
array(2) {
["/usr/share/nginx/html1/check.php"]=>
array(6) {
["full_path"]=>
string(32) "/usr/share/nginx/html1/check.php"
["hits"]=>
int(0)
["memory_consumption"]=>
int(1056)
["last_used"]=>
string(24) "Mon Dec 23 23:38:47 2013"
["last_used_timestamp"]=>
int(1387827527)
["timestamp"]=>
int(1387825174)
}
["/usr/share/nginx/html/index.php"]=>
array(6) {
["full_path"]=>
string(31) "/usr/share/nginx/html/index.php"
["hits"]=>
int(0)
["memory_consumption"]=>
int(1032)
["last_used"]=>
string(24) "Mon Dec 23 23:38:35 2013"
["last_used_timestamp"]=>
int(1387827515)
["timestamp"]=>
int(1387825100)
}
}
Run Code Online (Sandbox Code Playgroud)
如您所见,第二个池已经在缓存中有index.php,所以答案是所有4个池将共享128MB缓存.