# php-fpm runs 100% on reboot but not restart



## dvl@ (Aug 17, 2015)

I have a FreeBSD jail with php55-5.5.27 installed.  After the jail is restarted (booted), I see this:


```
last pid: 32067;  load averages:  6.76,  6.58,  6.08                                                                                                        up 0+02:04:41  20:24:05
24 processes:  6 running, 18 sleeping
CPU: 46.7% user,  0.0% nice, 32.0% system,  0.0% interrupt, 21.3% idle
Mem: 2293M Active, 2278M Inact, 16G Wired, 3164K Cache, 11G Free
ARC: 12G Total, 10G MFU, 755M MRU, 9872K Anon, 544M Header, 543M Other
Swap: 2048M Total, 2048M Free

  PID USERNAME    THR PRI NICE   SIZE    RES STATE   C   TIME    WCPU COMMAND
16450 www           1 103    0   234M 23144K CPU5    5  21:09 100.00% php-fpm
16829 www           1 103    0   234M 23148K CPU7    7  21:09 100.00% php-fpm
16831 www           1 103    0   234M 23148K CPU0    0  21:07 100.00% php-fpm
15760 www           1 103    0   234M 23144K CPU3    3  21:10  98.97% php-fpm
15759 www           1 103    0   234M 23144K CPU6    6  21:11  98.88% php-fpm
```

Restarting the service settles it.  I don't want to do this every time the jail (or the host) restarts.

Have you seen this before?


----------



## dvl@ (Aug 17, 2015)

Oops.  See also https://forums.freebsd.org/threads/php-fpm-5-4-13-takes-up-all-cpu-resources.38835/page-2 where this seems to be a long standing issue.


----------



## dvl@ (Aug 20, 2015)

I found a clue here: http://serverfault.com/questions/65...te-enough-children-and-stops-serving-requests

In /usr/local/etc/php-fpm.conf I changed


```
pm = dynamic
```
to

```
pm = ondemand
```

NOTE: This merely delayed the problem until the first request arrived.


----------



## dvl@ (Aug 20, 2015)

I have abandoned Nginx & php-fpm and moved to Apache & mod_rewrite.


----------



## junovitch@ (Aug 26, 2015)

Perhaps doing a `kldload dtraceall` and something like `perl /usr/share/dtrace/toolkit/hotuser -p <PID>` will help give some clues on what PHP is doing.


----------

