开发者

Sleeping php processes (mod_fcgid) counsuming RAM rapidly

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?


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

Instead of creating a new process for each request, FastCGI uses persistent processes to handle a series of requests. These processes are owned by the FastCGI server, not the web server.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜