休眠 php 进程 (mod_fcgid) 快速消耗 RAM
我希望这是问这个问题的正确地方,所以:
我们正在运行一个 Debian(虚拟化)服务器,其中 Apache 运行 php 作为 fcgi。今天管理员告诉我,这些进程正在消耗系统上的 RAM。他让我看看我的代码。
好吧,我认为实际上我无法控制 php 进程,因为 Apache 生成了它们,所以这看起来更像是服务器配置问题。似乎每个请求都会产生一个新的 php 进程(这是可以的)。我的脚本终止后,php 进程就会进入睡眠状态。
这就是 top 的样子。我按内存排序,这些是 php 进程(它们在用户 edem 上运行):
top - 14:49:35 up 41 days, 2:09, 2 users, load average: 0.16, 0.13, 0.06
Tasks: 228 total, 1 running, 227 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.3%sy, 0.0%ni, 98.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12358 edem 20 0 67380 6464 2976 S 0.3 0.2 0:00.06 php
12250 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12253 edem 20 0 67480 7812 3832 S 0.0 0.3 0:00.19 php
12254 edem 20 0 67464 7108 3316 S 0.0 0.2 0:00.07 php
12255 edem 20 0 67404 7340 3604 S 0.0 0.2 0:00.14 php
12256 edem 20 0 67464 7128 3336 S 0.0 0.2 0:00.07 php
12257 edem 20 0 67380 6484 3000 S 0.0 0.2 0:00.04 php
12258 edem 20 0 67464 7092 3312 S 0.0 0.2 0:00.05 php
12259 edem 20 0 67464 7184 3392 S 0.0 0.2 0:00.07 php
12260 edem 20 0 67464 7088 3296 S 0.0 0.2 0:00.06 php
12263 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12265 edem 20 0 67464 7084 3280 S 0.0 0.2 0:00.09 php
12266 edem 20 0 67436 7376 3600 S 0.0 0.2 0:00.14 php
12267 edem 20 0 67464 7144 3340 S 0.0 0.2 0:00.06 php
12268 edem 20 0 67380 6508 3016 S 0.0 0.2 0:00.05 php
12269 edem 20 0 67540 7672 3820 S 0.0 0.2 0:00.22 php
12270 edem 20 0 67496 6488 3040 S 0.0 0.2 0:00.05 php
12271 edem 20 0 67436 7372 3596 S 0.0 0.2 0:00.15 php
12272 edem 20 0 67464 7108 3304 S 0.0 0.2 0:00.07 php
12277 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12279 edem 20 0 67436 7368 3596 S 0.0 0.2 0:00.15 php
12280 edem 20 0 67464 7096 3296 S 0.0 0.2 0:00.07 php
12281 edem 20 0 67464 7748 3808 S 0.0 0.2 0:00.18 php
12282 edem 20 0 67496 7388 3600 S 0.0 0.2 0:00.14 php
12283 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.04 php
12284 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.05 php
12285 edem 20 0 67464 7168 3368 S 0.0 0.2 0:00.07 php
12286 edem 20 0 67464 7104 3304 S 0.0 0.2 0:00.06 php
12287 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12289 edem 20 0 67464 7140 3336 S 0.0 0.2 0:00.07 php
您知道如何杀死那些睡眠(空闲)的 php 进程吗?我做错了什么吗?
I hope that this is the right place to ask this question, so:
We are running a Debian (virtualized) server with Apache running php as fcgi. Today the administrator told me that the processes are consuming the RAM on the system. He asked me to look around my code.
Well I think that virtually I have no control over the php processes since Apache spawns them, so this seems more like a server configuration problem. It seems that every request spawns a new php process (this is ok). After my script terminates the php process goes to sleep.
This is what top looks like. I sorted by memory and these are the php processes (they run on the user edem):
top - 14:49:35 up 41 days, 2:09, 2 users, load average: 0.16, 0.13, 0.06
Tasks: 228 total, 1 running, 227 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.7%us, 0.3%sy, 0.0%ni, 98.7%id, 0.0%wa, 0.0%hi, 0.3%si, 0.0%st
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
12358 edem 20 0 67380 6464 2976 S 0.3 0.2 0:00.06 php
12250 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12253 edem 20 0 67480 7812 3832 S 0.0 0.3 0:00.19 php
12254 edem 20 0 67464 7108 3316 S 0.0 0.2 0:00.07 php
12255 edem 20 0 67404 7340 3604 S 0.0 0.2 0:00.14 php
12256 edem 20 0 67464 7128 3336 S 0.0 0.2 0:00.07 php
12257 edem 20 0 67380 6484 3000 S 0.0 0.2 0:00.04 php
12258 edem 20 0 67464 7092 3312 S 0.0 0.2 0:00.05 php
12259 edem 20 0 67464 7184 3392 S 0.0 0.2 0:00.07 php
12260 edem 20 0 67464 7088 3296 S 0.0 0.2 0:00.06 php
12263 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12265 edem 20 0 67464 7084 3280 S 0.0 0.2 0:00.09 php
12266 edem 20 0 67436 7376 3600 S 0.0 0.2 0:00.14 php
12267 edem 20 0 67464 7144 3340 S 0.0 0.2 0:00.06 php
12268 edem 20 0 67380 6508 3016 S 0.0 0.2 0:00.05 php
12269 edem 20 0 67540 7672 3820 S 0.0 0.2 0:00.22 php
12270 edem 20 0 67496 6488 3040 S 0.0 0.2 0:00.05 php
12271 edem 20 0 67436 7372 3596 S 0.0 0.2 0:00.15 php
12272 edem 20 0 67464 7108 3304 S 0.0 0.2 0:00.07 php
12277 edem 20 0 66960 9776 6584 S 0.0 0.3 0:00.11 php
12279 edem 20 0 67436 7368 3596 S 0.0 0.2 0:00.15 php
12280 edem 20 0 67464 7096 3296 S 0.0 0.2 0:00.07 php
12281 edem 20 0 67464 7748 3808 S 0.0 0.2 0:00.18 php
12282 edem 20 0 67496 7388 3600 S 0.0 0.2 0:00.14 php
12283 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.04 php
12284 edem 20 0 67380 6464 2976 S 0.0 0.2 0:00.05 php
12285 edem 20 0 67464 7168 3368 S 0.0 0.2 0:00.07 php
12286 edem 20 0 67464 7104 3304 S 0.0 0.2 0:00.06 php
12287 edem 20 0 66960 9780 6584 S 0.0 0.3 0:00.11 php
12289 edem 20 0 67464 7140 3336 S 0.0 0.2 0:00.07 php
Do you have any ide how to kill those sleeping (idling) php processes? Is there something I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
edem,我认为你不应该杀他们。由于 fastcgi 的想法是不产生新进程。请参阅http://en.wikipedia.org/wiki/FastCGI#Implementation_details
作为解决方法,您可以尝试使用网络服务器 fcgi 设置来减少“sleepin”数量。另外,我认为您的管理员会告诉您一些高峰使用情况,但我们在这里看不到它,因为您在可能的平静时间达到了最高记忆力。
edem, I think you shouln't kill em. As fastcgi idea not to spawn new processes. See http://en.wikipedia.org/wiki/FastCGI#Implementation_details
As a workaround you can try to play with your webserver fcgi settings to for example reduce "sleepin" number. Also I think your admin tells you about some peak usage, but we don't see it here, as you top your memory in possible calm time.