gpt4 book ai didi

php - 每个 php-fpm 池都有自己的内存池吗?

转载 作者:可可西里 更新时间:2023-11-01 13:21:13 25 4
gpt4 key购买 nike

假设我正在使用 PHP 5.5 操作码缓存,并设置

opcache.memory_consumption=128

,如果我在 php-fpm 中有 4 个池,这 4 个池中的每一个都会共享 128MB 的缓存,还是它们会为每个池拥有 128M 的 opcache?

最佳答案

如果您对池之间如何使用缓存内存有任何疑问,请进行简单测试。

技术很简单。在不同的 www-dir 上创建 2 个 fpm-pools 监听例如 8081 和 8082 端口和 2 个文件 index.phpcheck.php 具有相同的内容:

<?php
echo "<pre>\n";
var_dump(opcache_get_status());

首先重启你的 php-fpm 服务,然后先运行 pool localhost:8081/index.php,然后运行 ​​localhost:8082/check.php。在此之后检查输出中的 ["scripts"] 部分。我有下一个结果:

localhost: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)
}
}

localhost: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)
}
}

如您所见,第二个池已在缓存中包含 index.php,因此答案是所有 4 个池将共享 128MB 的缓存

关于php - 每个 php-fpm 池都有自己的内存池吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20570437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com