Kit*_*dia 5 php memory php-fpm opcache
我开始使用 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 = www\ngroup = www\nlisten = 127.0.0.1:9002\nlisten.owner = www\nlisten.group = www\n\nlisten.allowed_clients = 127.0.0.1\npm = ondemand\npm.max_children = 100\npm.process_idle_timeout = 5s;\nRun Code Online (Sandbox Code Playgroud)\n\nphp.ini:
\n\n[PHP]\nengine = On\nshort_open_tag = Off\nasp_tags = Off\nprecision = 14\ny2k_compliance = On\noutput_buffering = 4096\nzlib.output_compression = Off\nimplicit_flush = Off\nunserialize_callback_func =\nserialize_precision = 17\nallow_call_time_pass_reference = Off\nsafe_mode = Off\nsafe_mode_gid = Off\nsafe_mode_include_dir =\nsafe_mode_exec_dir =\nsafe_mode_allowed_env_vars = PHP_\nsafe_mode_protected_env_vars = LD_LIBRARY_PATH\ndisable_functions = escapeshellcmd, exec, ini_restore, passthru, popen, proc_nice, proc_open, shell_exec, show_source, system\ndisable_classes =\nzend.enable_gc = On\nexpose_php = Off\nmax_execution_time = 120\nmax_input_time = 300\nmemory_limit = 512M\nerror_reporting = E_ALL & ~E_DEPRECATED\ndisplay_errors = Off\ndisplay_startup_errors = Off\nlog_errors = On\nlog_errors_max_len = 1024\nignore_repeated_errors = Off\nignore_repeated_source = Off\nreport_memleaks = On\ntrack_errors = Off\nhtml_errors = Off\nerror_log = /var/log/nginx/php_error.log\nvariables_order = "GPCS"\nrequest_order = "GP"\nregister_globals = Off\nregister_long_arrays = Off\nregister_argc_argv = Off\nauto_globals_jit = On\npost_max_size = 2000M\nmagic_quotes_gpc = Off\nmagic_quotes_runtime = Off\nmagic_quotes_sybase = Off\nauto_prepend_file =\nauto_append_file =\ndefault_mimetype = "text/html"\ndoc_root =\nuser_dir =\nenable_dl = Off\ncgi.fix_pathinfo = 0\nfile_uploads = On\nupload_max_filesize = 200M\nmax_file_uploads = 200\nallow_url_fopen = On\nallow_url_include = Off\ndefault_socket_timeout = 60\nRun Code Online (Sandbox Code Playgroud)\n\n希望我能在这里找到已经遇到这个问题并能够解决它的人。所以我的最后一个问题是:如何配置 OpCache,以便在可用内存已满时将其清除?
\n我现在可以验证我的情况出了什么问题:
\n\n我使用一个软件,它能够删除自己的缓存,并且使用软件包系统,您可以在其中安装新软件包。
\n\n每当我安装新软件包或清除缓存时,软件都会运行 aopcache_reset()而不仅仅是使用opcache_invalidate(),因为它知道哪些文件将被更改\xe2\x80\xa6
| 归档时间: |
|
| 查看次数: |
3765 次 |
| 最近记录: |