- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我最近遇到了一个问题,php-fpm 进程的使用(如事件进程的数量)达到最大可用进程的峰值,并停止执行其他脚本,直到有问题的进程完成。
更详细一点,我当前的 php-fpm 设置是:
pm = static
pm.max_children = 100
我在看 php-fpm 的状态页面,大部分时间显示:
total processes: 100
idle processes: 95-99
active processes: 1-5
这是正常的。但是,每隔几分钟,事件进程数就会跳到 100 几秒钟,然后恢复到 1-5 的正常值。在那段时间里,服务器上运行的所有其他脚本都只是停留在那段时间。 (从浏览器中您只看到页面等待)。
现在,我检查了它是否在特定的流量高峰期,但事实并非如此。它也可能发生在当天流量最少的时候。
我相信某个脚本,甚至可能只在特定情况下,导致 php 出于某种原因简单地使用所有可用进程。
当我们从 5.2.X 迁移到 PHP 5.4.X 时,这个问题就开始了
我们目前有大约 60 个网站,因此很难浏览每个网站的页面并进行检查。
nginx 日志中没有任何内容(反正没有什么重要的,有一些通知等)。
我想做的是以某种方式跟踪/分析/监控哪个 php-fpm 脚本正在使用这些进程,这样我就知道从哪里开始寻找问题。
这可能吗?也许是不同的方法?
更新
这是 1 小时内 PHP-FPM 进程计数的图表,间隔为 1 分钟:
我用红色标记了我正在谈论的跳跃。峰值时的内存使用保持不变
最佳答案
在您的 php-fpm 日志文件中,您应该能够看到如下内容:
WARNING: [pool www-images] server reached pm.max_children setting (5), consider raising it.
当事件进程数达到限制时。您应该能够将其与传入的请求相关联。
如果这没有显示出导致问题的请求的任何模式,那么您应该将慢速日志记录添加到您的 php-fpm 配置中:
request_slowlog_timeout = 10
slowlog = /var/log/php-fpm/slow.$pool.log
将为每个占用超过 slowlog_timeout 限制的请求记录堆栈跟踪。
如果仍然没有显示任何内容,那么您的内部应用程序日志记录应该会显示减速发生的位置。
如果没有足够的细节,那么你可以使用 strace作为最后的手段,它将显示正在进行的系统调用。这将产生大量信息。我建议只将它附加到单个进程 strace -p PID
,其中 PID 是 php-fpm 实例的进程 ID。
it can also occur with the lowest traffic count of the day.
这肯定会出现在 php-fpm 慢速日志记录中。但是,如果这仅向您显示哪些请求很慢,而不能帮助您找出原因,您可以在 PHP-FPM 配置文件中使用自动前置和后置文件添加调试。
php_value[auto_prepend_file]=/php_shared/prepend.php
php_value[auto_append_file]=/php_shared/postpend.php
您可以设置 PHP-FPM 状态页面。
将此添加到您的 PHP-FPM 池配置中:
pm.status_path = /www-status
并通过nginx将请求传递给PHP-FPM
location ~ ^/(www-status)$ {
include %mysite.root.directory%/conf/fastcgi.conf;
fastcgi_pass unix:%phpfpm.socket%/php-fpm-www.sock;
# or IP address
# fastcgi_pass 127.0.0.1:9000;
#If you're fastcgi.conf doesn't set the query_string
#pass the query string here instead.
# fastcgi_param QUERY_STRING $query_string;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
allow 127.0.0.1;
allow stats_collector.localdomain;
allow watchdog.localdomain;
deny all;
}
然后转到 yoursite.com/www-status?full 将为您提供每个 php-fpm 进程的大字体,例如:
pool: www
process manager: dynamic
start time: 18/Mar/2013:20:17:21 +1100
start since: 243
accepted conn: 3
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 3
active processes: 1
total processes: 4
max active processes: 1
max children reached: 0
slow requests: 0
************************
pid: 6233
state: Idle
start time: 18/Mar/2013:20:17:21 +1100
start since: 243
requests: 1
request duration: 631
request method: GET
request URI: /www-status
content length: 0
user: -
script: /documents/projects/intahwebz/intahwebz/basereality/www-status
last request cpu: 0.00
last request memory: 262144
顺便说一句,我敢打赌是一些愚蠢的查询锁定了您的数据库。
关于nginx - php-fpm 进程监控/分析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15465333/
我已经在 ubuntu 14.0 上成功安装了 Zabbix 3.2 服务器主机上的 Z 是绿色的。不幸的是,JMX 是红色的。 Zabbix 服务器:192.168.1.112 带有 tomcat
我想制作一个仪表板,显示我们的 Azure 服务总线队列的状态,并显示“添加到队列的消息”、“队列长度”和“已处理的消息”等的历史记录。使用 Azure 管理门户,我可以看到,这些统计信息大部分是手动
我的 MYSQL 每天晚上都有事件,但我不太确定发生了什么,因为即使我将其设置得早于其他事件,它仍然在早上运行。 问题是,我如何检查运行事件的历史记录或日志,哪一个晚上锁了,哪一个是跑了没跑? 谢谢
1、监控log文件大小超过10g的server 和db 复制代码代码如下: create procedure db_sendmail_mssqllogsize as&n
本教程讨论如何使用 AspectJ 开源框架监控 Spring 应用程序在方法执行方面的性能。 传统上,监控每个 Java 方法所花费的时间的最简单方法是在方法的开头和结尾包含一些跟踪行: publi
有什么可以帮助 msmq 监控的吗?当消息出现在队列中并且在休假时相同时,我想获得一些事件/监视器。 最佳答案 查看 Windows 管理性能计数器。 如果您查看管理工具并找到“性能计数器”,您将能够
我的 Tomcat 中的一个巨大的 web 应用程序有时会开始使用过多的 DBCP 连接,从而导致问题。 为了进行调查,我想在每个时间点准确地知道什么线程/方法持有池的连接。不需要是实时的,事后分析就
在浏览器的整个页面生命周期中监视 cookie 并在 cookie 更改时触发事件的最佳 JS 或 JQuery 特定方法是什么? 最佳答案 据我所知,不可能将 change (或类似)事件直接绑定(
我想尽可能详细地报告我的笔记本的执行情况。简而言之,我想实时查看我的笔记本正在执行的每个操作。例如,我的一个函数有一个 sleep 周期为 5 秒的循环,我希望看到程序实际上正在 sleep 并且循环
Azure 容器服务是否与 Azure Monitor 集成?想知道对 kubernetes 集群进行日志记录/监控的最佳方法是什么? 最佳答案 如果您正在 Azure 上寻找监视工具,您可能需要使用
我一直在尝试使用 erlang:monitor/2 来监视 gen_server。不幸的是,每次我尝试这个时,Erlang shell 都会进入无限循环。 这是我为测试这一点而编写的测试程序。 -mo
Azure 容器服务是否与 Azure Monitor 集成?想知道对 kubernetes 集群进行日志记录/监控的最佳方法是什么? 最佳答案 如果您正在 Azure 上寻找监视工具,您可能需要使用
我想使用 编写一个 shell 脚本来监控集群中的消费者滞后 bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zkconnect
在 .NET 中,假设 thread A 锁定了一个对象。同时,线程B和线程C被阻塞,等待线程A解锁对象。 现在,线程 A 解锁了对象。接下来将选择哪个线程(B 或 C)?它是如何确定的? 最佳答案
我搜索过这个主题,但发现很少有有用的细节。有了这些细节,我尝试编写一些代码如下。 注意:在将此帖子标记为重复之前,请将此帖子中共享的详细信息与其他帖子进行比较,而不仅仅是按主题。 - (NSArray
目录 1、指标监控 2、常用的监控端点 3、定制EndPoint 4、spring boot admin(可以使用)
我们使用 Prometheus 和 Grafana 来监控我们的 Kafka 集群。 在我们的应用程序中,我们使用 Kafka 流,Kafka 流有可能因异常而停止。我们正在记录事件 setUnCau
我正在建立一个复杂的网络仿真,并试图捕捉一些重要的性能测量。 我在服务器上运行了 mininet,并且我将视频从一个 mininet 主机流式传输到另一个(使用 -nodisp 选项,因为我没有 GU
Jenkins 的 openstack-plugin 使用 openstack4j 与 openstack 云对话。我正在寻找一种方法,我们可以从客户端的角度监控 openstack4j 所做的 ht
我正在处理一项需要监控 Thunderbolt 端口连接变化的要求。 (当连接或断开 Thunderbolt 电缆时)。 我尝试使用 IOServiceMatching(kIOUSBInterface
我是一名优秀的程序员,十分优秀!