我的网络服务器上的 opcache 一直达到我设置的限制,即使我觉得我没有那么多 PHP 代码,它真的应该有足够的空间。
更糟糕的是,即使在清除 opcache 时,它也会立即显示超过 2/3 的可用空间已被填充。
刚才的例子:
运行 opcache_reset() 之前的 phpinfo 片段:
Used memory 122958472
Free memory 5552
Run Code Online (Sandbox Code Playgroud)
运行 opcache_reset() 后的 phpinfo 片段:
Used memory 90691312
Free memory 43526416
Run Code Online (Sandbox Code Playgroud)
我知道在 PHP7 中,opcache(显然)备份到磁盘,所以也许东西正在自动重新加载?但这似乎违背了重置 opcache 的目的,我不知道 opcache 备份到磁盘上的哪个位置,所以我无法检查。
我正在 nginx 上运行 PHP-FPM,准确地说是 vesion 7.0.15-0ubuntu0.16.04.4。
我开始使用 PHP 5.6 内置的 PHP OPcache,现在面临一个问题。我将其设置为最多使用 1 GB RAM,这对于我的网站来说已经足够了,但它永远无法使用完整的 1 GB RAM。在分配此限制之前,缓存会被清除多次,如您在 munin 图上看到的那样:
\n\n\n\n因此,每隔几天它就会从缓存中删除所有文件,然后重新开始缓存它们。
\n\n首先我认为问题出在变量上opcache.max_wasted_percentage,但它并不关心我设置的值。我的配置如下:
; configuration for php ZendOpcache module\n; priority=05\nzend_extension=opcache.so\nopcache.enable = 1\nopcache.enable_cli = 1\nopcache.memory_consumption = 1024\nopcache.interned_strings_buffer = 128\nopcache.blacklist_filename = /etc/php5/opcache_blacklist.txt\nopcache.max_accelerated_files = 65407\nopcache.revalidate_freq = 5\nopcache.fast_shutdown = 1\nopcache.max_wasted_percentage = 50\nopcache.enable_file_override = 1\nRun Code Online (Sandbox Code Playgroud)\n\n我\xe2\x80\x99m在带有nginx和FastCGI的最新Debian Jessie环境中使用它。
\n\n我想实现只有当内存消耗达到 1 GB 时才清除缓存。我已经尝试过一个非常小的配置,如下所示:
\n\n; configuration for php ZendOpcache module\n; priority=05\nzend_extension=opcache.so\nopcache.enable = 1\nopcache.enable_cli = 1\nopcache.memory_consumption = 1024\nRun Code Online (Sandbox Code Playgroud)\n\n即便如此,问题仍然存在。
\n\n如果需要 FPM 配置:
\n\nuser …Run Code Online (Sandbox Code Playgroud) 我们正在配置一个新服务器,并在 (php7 / opcache) 和 (php5.6 / xcache) 之间做出决定。
我们运营着一些庞大的电子商务网站,并希望获得最佳性能。
我正在寻找两者之间的比较结果,但在任何地方都找不到。
有没有人有两个并排的经验?
我已经使用 php-fpm 设置了 opcache,但由于某种原因,它不断手动重新启动。我没有执行重新启动操作,并且已将强制重新启动超时设置为 2700 秒(2 小时),因此缓存不应被清除。
是什么原因导致手动重启?
Array
(
[opcache_enabled] => 1
[cache_full] =>
[restart_pending] =>
[restart_in_progress] =>
[memory_usage] => Array(
[used_memory] => 58506120
[free_memory] => 478364792
[wasted_memory] => 0
[current_wasted_percentage] => 0
)
[interned_strings_usage] => Array(
[buffer_size] => 16777216
[used_memory] => 5840560
[free_memory] => 10936656
[number_of_strings] => 3946503
)
[opcache_statistics] => Array(
[num_cached_scripts] => 1553
[num_cached_keys] => 3015
[max_cached_keys] => 16229
[hits] => 52263
[start_time] => 1475655854
[last_restart_time] => 1475662737
[oom_restarts] => 0
[hash_restarts] => 0
**[manual_restarts] => …Run Code Online (Sandbox Code Playgroud) 有PHP-FPM和OPCache(从php.net下载并编译)
opcache.enable = 1
opcache.use_cwd = 1
zend_extension=opcache.so
Run Code Online (Sandbox Code Playgroud)
php-fpm 配置文件在 chroot 中运行,即/home/user1/www/index.php-> /www/index.php、/home/user2/www/index.php-> /www/index.php,这index.php两种情况下都会看到。
user1已经安装了WordPress。user2有定制index.php。
user1user2's index.php 在's之前执行index.php。
在这种情况下,当我index.php从文件夹调用时,我会看到来自文件夹user2的编译输出。index.phpuser1
目前的解决方案。我可以为每个用户运行不同的 PHP,否则我必须终止我漂亮的结构/home/user1/www,导致/home/user1/user1www/OPcache 需要查看不同的路径。或者我禁用OPcache,但它会影响性能。
有没有办法保留/home/user1/www、/home/user2/www等并让 OPcache 正常工作?