Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables or at least better defaults for PHP pm.* settings #1982

Closed
t3easy opened this issue May 15, 2023 · 6 comments
Closed

Variables or at least better defaults for PHP pm.* settings #1982

t3easy opened this issue May 15, 2023 · 6 comments

Comments

@t3easy
Copy link
Contributor

t3easy commented May 15, 2023

The default values for

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

are not usable in production in most Nextcloud installations.

In the new docs, there is a part that these settings should be changed depending on the available resources:
https://docs.nextcloud.com/server/26/admin_manual/installation/server_tuning.html#tune-php-fpm

Older docs had some example values:
https://docs.nextcloud.com/server/21/admin_manual/installation/server_tuning.html#tune-php-fpm

If these settings are not changed, the Nextcloud no longer responds when the load increases.

[pool www] server reached pm.max_children setting (5), consider raising it

The docker image should provide better defaults for PHP pm.* settings and environment variables to change them without building the image.

@J0WI
Copy link
Contributor

J0WI commented May 25, 2023

Duplicate of #1969

@J0WI J0WI marked this as a duplicate of #1969 May 25, 2023
@J0WI J0WI closed this as completed May 25, 2023
@rugk
Copy link
Contributor

rugk commented May 25, 2023

I think this issue is not actually a real duplicate IMHO. Could not you e.g.:

  • configure these settings to at least somewhat higher number?
  • at the first start of the container automatically calculate a value that is considered to be "good" (e.g. based on the ram or whatever) likely in a shell script
  • or, maybe in addition, include, if possible, a check for a good value in the Nextcloud "health/system check" admin page (would be am issue for the Nextcloud php project itself of course, however)?

@J0WI
Copy link
Contributor

J0WI commented May 25, 2023

There is some attempt in #1766 and #1964. We can't make any assumption about the host system. This may range from a tiny SOC board to a large root server and from single purpose hosts to one that shares it's resources with many other services. There is no "good" default or at least I'm not aware of a "good" way to calculate it.

@t3easy
Copy link
Contributor Author

t3easy commented May 26, 2023

@J0WI I would assume that a docker host has at least 4 GB RAM and is dedicated for the Nextcloud stack. If this parameters can be changed for larger or smaller hosts by environment variables like the PHP memory and upload limit https://github.com/nextcloud/docker/blob/master/26/fpm-alpine/Dockerfile#L81 this should be a good solution.
Otherwise you force the users to build an own image extending Nextcloud or mount a config into the container.

@t3easy
Copy link
Contributor Author

t3easy commented Jun 28, 2023

This is what I did:

FROM nextcloud:${NEXTCLOUD_VERSION}-fpm-alpine

# ...

ENV PHP_PM_MAX_CHILDREN=5
ENV PHP_PM_START_SERVERS=2
ENV PHP_PM_MIN_SPARE_SERVERS=1
ENV PHP_PM_MAX_SPARE_SERVERS=3

RUN set -eux; \
    { \
        echo '[www]'; \
        echo 'pm.max_children = ${PHP_PM_MAX_CHILDREN}'; \
        echo 'pm.start_servers = ${PHP_PM_START_SERVERS}'; \
        echo 'pm.min_spare_servers = ${PHP_PM_MIN_SPARE_SERVERS}'; \
        echo 'pm.max_spare_servers = ${PHP_PM_MAX_SPARE_SERVERS}'; \
    } | tee "/usr/local/etc/php-fpm.d/zz-pm.conf"

The defaults are those from /usr/local/etc/php-fpm.d/www.conf so there is no change for existing installations. I cloud provide a PR if you like.

@skl256
Copy link

skl256 commented Oct 19, 2023

@t3easy Thank you very mush! My problem (freeze when rewinding video) solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants