首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >50例PHP杀死了我的web服务器?

问50例PHP杀死了我的web服务器?
EN

Server Fault用户
提问于 2019-04-16 00:53:19
回答 1查看 531关注 0票数 1

我之前有个“记忆不足”的问题。我刚刚离开顶部打开,它冻结在屏幕上,因为它的内存耗尽。我有一个用户列出了大约50个实例的"php“列出。如何限制允许打开PHP实例的数量?还是允许单个用户使用的PHP实例数?为什么它使用这么多PHP实例?这是wordpress的网站。

EN

回答 1

Server Fault用户

回答已采纳

发布于 2019-04-16 01:07:27

基本上,默认的php配置是使用比可用RAM更多的RAM。您需要配置PHP,这样它就不会像这一个这样的指南那样耗尽资源。

代码语言:javascript
复制
sudo nano /etc/php/7.0/fpm/pool.d/www.conf

您需要决定要使用的PM类型。读这个。按需应变通常适用于低内存服务器,因为这些服务器的流量很少。我认为我对我的主PHP池使用了dynamic,因为它使一些PHP进程始终可用,等待服务请求,然后按需测试很少使用的PHP池。ondemand意味着需要启动更多的php进程延迟,但是对于较低的卷站点,这可能是可以的。

如果您的内存少,流量少,那么配置可能是这样的。

代码语言:javascript
复制
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中,您有可用的。

PHP5.6

在我的AWSt2上,我有两个池。下面是为生产请求提供服务的动态池的定义

文件:/etc/php 5.6.d/www.conf

代码语言:javascript
复制
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文件:

文件pm = ondemand pm.max_children = 2 pm.process_idle_timeout = 120s; pm.max_requests = 50

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/963203

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档