我之前有个“记忆不足”的问题。我刚刚离开顶部打开,它冻结在屏幕上,因为它的内存耗尽。我有一个用户列出了大约50个实例的"php“列出。如何限制允许打开PHP实例的数量?还是允许单个用户使用的PHP实例数?为什么它使用这么多PHP实例?这是wordpress的网站。
发布于 2019-04-16 01:07:27
基本上,默认的php配置是使用比可用RAM更多的RAM。您需要配置PHP,这样它就不会像这一个这样的指南那样耗尽资源。
sudo nano /etc/php/7.0/fpm/pool.d/www.conf您需要决定要使用的PM类型。读这个。按需应变通常适用于低内存服务器,因为这些服务器的流量很少。我认为我对我的主PHP池使用了dynamic,因为它使一些PHP进程始终可用,等待服务请求,然后按需测试很少使用的PHP池。ondemand意味着需要启动更多的php进程延迟,但是对于较低的卷站点,这可能是可以的。
如果您的内存少,流量少,那么配置可能是这样的。
pm = ondemand
; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5
; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
;pm.start_servers = 2
; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.min_spare_servers = 1
; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
;pm.max_spare_servers = 3
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 60s;
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 50如果您获得更高的流量,您可能会更好地使用动态和调优的值,以便您有足够的服务器运行在CPU / RAM中,您有可用的。
在我的AWSt2上,我有两个池。下面是为生产请求提供服务的动态池的定义
pm = dynamic
pm.start_servers = 2
pm.max_children = 4
pm.start_servers = 2
pm.max_spare_servers = 2
pm.min_spare_servers = 1
pm.max_requests = 25下面是我的测试池,用于我很少访问的测试服务器
/etc/php-fpm-5.6.d/testpool.conf文件:
https://serverfault.com/questions/963203
复制相似问题