# PHP-FPM defaults to pm.max\_children = 9999! How to globally set sane value for all existing virtual servers

**URL:** <https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480>\
**Category:** Virtualmin\
**Created:** [April 27, 2021, 12:56am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480 "2021-04-27T00:56:45Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronroydhouse](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/aaronroydhouse/32/890_2.png) [@aaronroydhouse](https://forum.virtualmin.com/u/aaronroydhouse)\
**Post date:** [April 27, 2021, 12:56am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/1 "2021-04-27T00:56:45Z")

</div>

**Operating system: Ubuntu Linux**  
**OS version: 18.04**  
**Virtualmin: 6.15**

Original 2017 issue highlighting this: [PHP-FPM pm.max\_children and control panel and server templates [#52223] | Virtualmin](https://www.virtualmin.com/node/52223)

Just dealt with a server swamping with PHP-FPM child processes. The ‘pm.max\_children’ was set to 9999 by default in all PHP-FPM pools. The default PHP-FPM settings are unreasonable and can’t find a global way to fix them. The sample config setting is `pm.max_children = 5` but Virtualmin used `pm.max_children = 9999`.

I can’t see any global way to fix this, unless adding it to ‘Additional FPM pool options’ will override the default pool setting? Or is there a template somewhere to edit? I can’t find any setting for this at the per-site level either. Though you can ‘manually edit config’ under Services → PHP-FPM options to change it. Ideally there would get a sensible starting default value and a global way to change/limit that.

**Refs for PHP-FPM settings issues:**

> [@PHP-FPM global configuration](https://forum.virtualmin.com/t/php-fpm-global-configuration/57629):
>
> Hi there ! I’ve a little problem to create many small servers with Virtualmin. Indeed, Virtualmin give too large resources by virtualserver. I would like change the default configuration of php-fpm.d/\*.conf. The default configuration : [id] user = userofsupervirtualser group = userofsupervirtualser listen = XXXX pm = dynamic pm.max\_children = 9999 pm.start\_servers = 1 pm.min\_spare\_servers = 1 pm.max\_spare\_servers = 5 php\_admin\_value[upload\_tmp\_dir] = /something/www/userofsupervirtu…

> [@PHP-FPM configuration](https://forum.virtualmin.com/t/php-fpm-configuration/60449):
>
> Hi, I am new to virtualmin. I have 4 core and 4gb ram Virtualmin GPL server with around 30-40 websites 30-40 but not much traffics. However, my ram is always full and it keeps on shutting down mysql database. After some research, I have changed my apache configuration in /etc/httpd/conf.d/z-optimize.conf to ServerLimit 150 StartServers 4 MinSpareThreads 25 MaxSpareThreads 75 ThreadLimit 64 …

[https://www.virtualmin.com/node/54678#comment-811858](https://www.virtualmin.com/node/54678#comment-811858)

---

<div class="post-metadata">

**Author:** ![calport](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/calport/32/44_2.png) [@calport](https://forum.virtualmin.com/u/calport)\
**Post date:** [April 27, 2021, 1:04am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/2 "2021-04-27T01:04:25Z")

</div>

> [@aaronroydhouse](#):
>
> can’t find a global way to fix them

Try this - I fixed over 200 virtual servers in under a minute.

 ![image](https://cdn.forum.virtualmin.com/uploads/default/original/2X/9/9c63a345c5f04800f532b3edc232e5cb54cc0bc9.png)

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [April 27, 2021, 1:10am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/3 "2021-04-27T01:10:14Z")

</div>

Yes, there is a template (Server Templates-\>PHP Options, probably).

But, also, this is a bug. That’s nonsensically high. I’m not sure where the `9999` comes from, but it should never be that high. Reasonable numbers are in the tens (based on RAM, as I understand it), not thousands.

@Jamie can `pm.max_children` be made more reasonable by default? Something like 10 or 20?

---

<div class="post-metadata">

**Author:** ![Jamie](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/jamie/32/8589_2.png) [@Jamie](https://forum.virtualmin.com/u/Jamie)\
**Post date:** [April 27, 2021, 3:32am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/5 "2021-04-27T03:32:04Z")

</div>

We’re using 9999 as a proxy for “unlimited” since there’s no actual unlimited option in the config.

I can lower it to 20 by default though.

---

<div class="post-metadata">

**Author:** ![aaronroydhouse](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/aaronroydhouse/32/890_2.png) [@aaronroydhouse](https://forum.virtualmin.com/u/aaronroydhouse)\
**Post date:** [April 27, 2021, 3:56am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/6 "2021-04-27T03:56:59Z")

</div>

> [@Joe](#):
>
> Yes, there is a template (Server Templates-\>PHP Options, probably).

No, that only provides templates for the `php.ini` file not for the PFM pool file. There is a `Additional FPM pool options` setting though, and I’m wondering if that gets added to the end of the pool config file if that could override the the built in `9999` default.

> [@calport](#):
>
> Try this - I fixed over 200 virtual servers in under a minute.

If it came to that I was just going to use `sed` but that’s a great Web UI tip 👏

> [@Jamie](#):
>
> We’re using 9999 as a proxy for “unlimited” since there’s no actual unlimited option in the config.  
> I can lower it to 20 by default though.

Cool. Any plausible/reasonable default is fine. I think more people would be rolling with 5-20 than people who would genuinely want 30% of the process ID space used by every site 😃 Maybe the same default as the FCGI sub-processes - which is roughly the same thing? That defaults to 20 I think and is changeable in `Server Configuration -> PHP Options`.

Ideally this FPM pool value would be one of the settings or part of an editable template under `Server Templates -> PHP Options` or `Virtualmin Configuration -> PHP Options` at the global/default/template level, and then one of the `Services -> PHP-FPM Configuration -> Resource Limits` at the site level.

Given HTTP/2 is \> 50% of all traffic now and HTTP/3 is coming, the days when we can use anything other than FPM are numbered. The old CGI/FCGI stuff should be deprecated and eventually removed IMO.

---

<div class="post-metadata">

**Author:** ![Joe](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/joe/32/9_2.png) [@Joe](https://forum.virtualmin.com/u/Joe)\
**Post date:** [April 27, 2021, 7:18am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/7 "2021-04-27T07:18:12Z")

</div>

> [@aaronroydhouse](#):
>
> Given HTTP/2 is \> 50% of all traffic now and HTTP/3 is coming, the days when we can use anything other than FPM are numbered. The old CGI/FCGI stuff should be deprecated and eventually removed IMO.

See here: [Virtualmin 7 checklist · Issue #42 · virtualmin/virtualmin-install · GitHub](https://github.com/virtualmin/virtualmin-install/issues/42)

But, we get a _lot_ of pushback for changes like that. We still have folks enabling mod\_php ten years after it made sense to do so.

---

<div class="post-metadata">

**Author:** ![aaronroydhouse](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/aaronroydhouse/32/890_2.png) [@aaronroydhouse](https://forum.virtualmin.com/u/aaronroydhouse)\
**Post date:** [April 27, 2021, 7:40am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/8 "2021-04-27T07:40:12Z")

</div>

Thanks for the reference.

Totally understand about push-back. That’s why I said deprecate rather than remove any time soon. I’d mostly like to see the default, OOB install be a modern configuration. And the legacy, anti-pattern tools to be optional installs with ‘educational’ banners/messages on the setting dialogs. Maybe a subtle red color for the legacy menu items just to feel ominous. 😃

Changing the defaults for 7 would go a long way. Right now it is actually a bit tricky to convert a 6.x install to support HTTP/2. Get it working and work our what to (safely) remove. And there’s a few rough edge with FPM site conversions and updates. I’d prefer to see FPM use named sockets owned by the site account in the rather than port numbers from the shared server pool, with all the security and renumbering issues that brings.

If you start with 7 supports HTTP/2 HTTP/3 OOB, then a lot of things work backwards from that. You want to enable X old bad thing? We’d love to, but you know you’ll have to go disable HTTP/2 for that, oh btw HTTP/1.1 will make your performance suck, “proceed yes or no?”. 😃

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [April 27, 2021, 9:16am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/9 "2021-04-27T09:16:14Z")

</div>

> [@Jamie](#):
>
> I can lower it to 20 by default though.

Jamie, ideally this value should be calculated based on the amount of RAM available. We could also tie it to post-configuration wizard, where you define how databases are used (_Small_, _Medium_, _Large_, _Huge_).

---

<div class="post-metadata">

**Author:** ![calport](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/calport/32/44_2.png) [@calport](https://forum.virtualmin.com/u/calport)\
**Post date:** [April 27, 2021, 10:34am UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/10 "2021-04-27T10:34:31Z")

</div>

The database server cannot be configured on a per virtual server basis (well, maybe it can, but…) however the PHP-FPM pool makes it easy to configure each virtual server to receive only an allotted number of child processes. If this could be tied in with Account Plans or Server Templates then wow - I could charge a premium from the owner of that WordPress site which has Elementor installed with a zillion addons.

Just an idea… #FeatureRequest

---

<div class="post-metadata">

**Author:** ![Gomez\_Adams](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/gomez_adams/32/3221_2.png) [@Gomez\_Adams](https://forum.virtualmin.com/u/Gomez_Adams)\
**Post date:** [April 27, 2021, 12:38pm UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/11 "2021-04-27T12:38:18Z")

</div>

I absolutely loath Elementor. It’s bloatware beyond the pale. Sadly, it’s tied into the most popular Wordpress template available: OceanWP.

---

<div class="post-metadata">

**Author:** ![system](https://cdn.forum.virtualmin.com/uploads/default/original/2X/c/cd96d761e326db4b2bef94886a639109bd7a8e76.svg) [@system](https://forum.virtualmin.com/u/system)\
**Post date:** [June 26, 2021, 12:39pm UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/12 "2021-06-26T12:39:07Z")

</div>

Closed on June 26, 2021, 12:39pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![Ilia](https://cdn.forum.virtualmin.com/user_avatar/forum.virtualmin.com/ilia/32/10185_2.png) [@Ilia](https://forum.virtualmin.com/u/Ilia)\
**Post date:** [September 3, 2022, 12:33pm UTC](https://forum.virtualmin.com/t/php-fpm-defaults-to-pm-max-children-9999-how-to-globally-set-sane-value-for-all-existing-virtual-servers/110480/13 "2022-09-03T12:33:40Z")

</div>

This issue is going to be solved with Virtualmin 7.2 release.
