3

I'm not much of a system / network administrator. I'm searching for a way to properly determine the settings of my php-fpm.

So far I found this article explaining the details to calculate these settings based on the server specs (https://chrismoore.ca/2018/10/finding-the-correct-pm-max-children-settings-for-php-fpm/):

pm.max_children
pm.start_servers
pm.min_spare_servers
pm.max_spare_servers

But there's a setting here pm.max_requests, so I'm wondering what value I should put here? How do I determine what value I should put there? Should I leave it at default 0?

6
  • 1
    What are you trying to achieve here? To me, it just looks like you want to populate settings just because you want to do it - not because you actually have found a need to. 99.9999% of cases - you can just let it be the default value.
    – Orphans
    Commented Oct 8, 2022 at 13:27
  • @Orphans , I think you misunderstood my motive here, you're assuming. I just want to know what are the optimal settings to put. In my question details I mention that I'm not much of a system administrator. I don't any experience doing this things, that's why I'm asking it here. Also in my question I put there "Should I leave it at default 0?". Commented Oct 9, 2022 at 4:34
  • Hi @aceraven777, I'd suggest you to look for my answers regarding capacity in other serverfault messages.
    – Marcel
    Commented Oct 10, 2022 at 8:46
  • 1
    Performance tuning and tuning in general is as much an art as a science. You need data (obtained by careful monitoring), actual load (by either synthetic running load generators & stress tests and/or on your production environment) to identify bottle necks , before selecting and adjusting certain specific potentially beneficial settings and then measure the effect of those changes. Generally most settings don't have fixed formula, no sigma(#cores) / gamma(#RAM memory) ^ psi(#concurrent users) * rho(moon phase), that result in an "optimal" value. Much depends on your own use-cases.
    – diya
    Commented Oct 10, 2022 at 9:57
  • 1
    php.net/manual/en/install.fpm.configuration.php explains what the setting does : "pm.max_requests int The number of requests each child process should execute before respawning. This can be useful to work around memory leaks ... Default value: 0." - based on that info: As a sysadmin I would adjust the default when monitoring shows that over time each php_fpm process starts consuming more and more memory (indicating a memory leak somewhere) and otherwise there is no immediate need to adjust the default value.
    – diya
    Commented Oct 10, 2022 at 10:02

1 Answer 1

3
+50

The only possible answer here is that there is no exact answer to give.

It really depends. Performance settings are solely dependent on each use-case, specs, project structure, etc.


You should only set a value here if you have a reason to.

If you don't care how many requests each process can get before restarting, you should just leave it at the default setting.

The same can be said for most settings in all sorts of applications, not just PHP-FPM.


From the docs:

pm.max_requests

The number of requests each child process should execute before respawning. This can be useful to work around memory leaks in 3rd party libraries. For endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. Default value: 0.

So, ask yourself: Are you having an issue with memory leaks, hung connections, etc? If so, maybe this functionality would be useful to you. If not, maybe just leave it alone.

I'll summarize with an analogy: Just because you have a workshop full of tools, it does not mean you need every tool for every job. This setting only needs to be configured if there is a problem to solve.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .