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

where to set pm.max_children #275

Open
oculos opened this issue Jan 13, 2025 · 18 comments
Open

where to set pm.max_children #275

oculos opened this issue Jan 13, 2025 · 18 comments

Comments

@oculos
Copy link

oculos commented Jan 13, 2025

When searching on my site, friendica gets unresponsive. I see in the logs that it asks to raise the value of pm.max_children.

However, on the docker image I can't find those settings.

Could you help me?

@ne20002
Copy link
Collaborator

ne20002 commented Jan 31, 2025

Just mount your own php config file into the container like described here:

https://serverfault.com/questions/884256/how-and-where-to-configure-pm-max-children-for-php-fpm-with-docker

Does this help?

@oculos
Copy link
Author

oculos commented Jan 31, 2025 via email

@ne20002
Copy link
Collaborator

ne20002 commented Jan 31, 2025

It's always difficult to decide what configuration values shall be available as env variables for a docker image. There are many.
As you're the first asking for this I'd rather go with the 'mounting your own config file' approach.

@oculos
Copy link
Author

oculos commented Jan 31, 2025 via email

@ne20002
Copy link
Collaborator

ne20002 commented Jan 31, 2025

As said, it's the first time I hear this but I'm willing to take a deeper look on the issue. Which version of friendica and which docker image are you using? How many users do ou have on the system?

@nupplaphil, @annando, @MrPetovan maybe you can help? Is pm.max_children ever been an issue?

@oculos
Copy link
Author

oculos commented Jan 31, 2025 via email

@MrPetovan
Copy link
Collaborator

I'm still using the Apache2 PHP module over here, so I'd be hard-pressed to give advice on php-fpm. 😕

@ne20002
Copy link
Collaborator

ne20002 commented Jan 31, 2025

Fair enough. But the issue here is that Friendica is almost unusable with the default configs. pm.macx_children leads quickly to errors with the default values.

@oculos, as these kind of warnings often don't point the problem and as you are the first to ask I don't want to put too much effort into adding this as an env variable. I also don't have the setup to test it. But a dozen users shouldn't give friendica any problems, not even on a raspberry pi.

I suggest you try to fix this by mounting your own config file into the container and check if you can resolve the issue by modifying values. If this is successful we will hopefully get more information to decide how to handle this. Is this ok?

@oculos
Copy link
Author

oculos commented Feb 9, 2025

I saw today that I got these with the default docker:

PHP Fatal error:  Allowed memory size of 4294967296 bytes exhausted (tried to allocate 8388616 bytes) in /var/www/html/src/Protocol │
│

@m33m33
Copy link

m33m33 commented Feb 9, 2025

There is the Site / administration / workers pannel in the admin console webui where you can set Maximum number of parallel workers

It may be

  • the good place to add pm.* parameters one day
  • an inspiration so keep pm.max_children in sync with Maximum number of parallel workers

@ne20002
Copy link
Collaborator

ne20002 commented Feb 27, 2025

This details of process handling in php are beyond my knowledge (tended to write paygrade ;)

But looking at @m33m33 's answer about syncing pm.max_children and Number of parallel workers I'm not sure we can modifiy a php config file from the Friendica web app.
Also, is it required to keep them in sync? What is the impact?

@MrPetovan
Copy link
Collaborator

Parallel workers are spawned using PHP CLI, nothing to do with PHP-FPM, so there's no reason to link them together. Also Friendica indeed can't change fpm's configuration.

@m33m33
Copy link

m33m33 commented Feb 27, 2025

Does this also apply to fpm images ?

@ne20002
Copy link
Collaborator

ne20002 commented Feb 27, 2025

It seems that pm.max_children and related settings are usually calculated based on the available memory and the average/max memory used per process.
For the docker images I would default to 1GB of memory.
But what is the average/max memory usage of processes by Friendica?
Any suggestions?

@MrPetovan
Copy link
Collaborator

I have a 512Mb max memory per script execution on my Apache install, not sure if it's relevant.

@ne20002
Copy link
Collaborator

ne20002 commented Feb 27, 2025

This is one source I found (others are similar). I think when we collect the info from different systems we may get a pretty good number to use.

@oculos
Copy link
Author

oculos commented Feb 27, 2025 via email

@ne20002
Copy link
Collaborator

ne20002 commented Feb 28, 2025

We must find a good starting point at first. One good for most and hobby users. Friendica is running on a small machine with only 1GB RAM, e.g. Raspi or VPS.
When raising these values we need to ensure that those instances don't get into trouble.

Configuration is a good thing. The easiest way is always to mount your own config file into the container. As those configuration require knowledge (or try and error or both) I assume people needing tweaking these values know how to do this and how to work with dockerized applications.

Maxing these configuration values need info about the machine and can not easily be collected (e.g. memory on a machine running multiple applications with docker 'sharing' its memory).

Let's see where we land with a new default.

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