Set php.ini memory allocation to match Cloudron memory allocated
-
Prob a Q for @girish
It seems Wordpress doesn't recognised the allocated memory from the Cloudron app memory allocation, so it needs setting in
php.ini
with:memory_limit = 2048M
or whatever value.
Perhaps this should be set and updated to keep in sync with the Cloudron app memory allocation setting?
-
The app's memory limit is actually spread over the apache instances. The number of apache instances in turn comes from the apache configuration. The number of apache instances at a time is dynamic based on how many servers you keep running non-stop and how many you recycle. After that, each apache loads mod_php and mod_php uses the php memory to run the PHP VM. It's not straightforward to map the container memory limit into php memory limit.
-
@girish OK, I didn't spot anything in the documentation, but maybe worth adding a line, as we thought WP had all the memory allocated to play with, but was only using 256MB without that being set in the php.ini, which caused cron jobs to fail, as they run out of memory, as tending to do more memory intense things.
-
@girish said in Set php.ini memory allocation to match Cloudron memory allocated:
The app's memory limit is actually spread over the apache instances. The number of apache instances in turn comes from the apache configuration. The number of apache instances at a time is dynamic based on how many servers you keep running non-stop and how many you recycle. After that, each apache loads mod_php and mod_php uses the php memory to run the PHP VM. It's not straightforward to map the container memory limit into php memory limit.
Huh? To clarify things a little more, does that mean that, after all, it's still better to adjust memory settings in php.ini for PHP apps?
Honestly, I understand the part that loads the required memory to run the PHP app through the Apache instance, but from your explanation it's not clear, for me at the very least, on how exactly the memory allocation feature of Cloudron, interacts with the VM's memory finally... -
@micmc Correct. Surprised me, too, but that's the way it is. Thought to post, as I think it's obscure enough that most wouldn't have noticed.
Install the Query Monitor Plugin in Wordpress and look at the output before and after adding this setting and restarting the app, and you'll see what I mean.
-
@micmc If it helps: setting memory limit for an app (at the Cloudron level) is like creating a virtual server with that much memory. So, if you allocate 2GB, it's like creating a 2GB server. Inside this 2GB server, there is apache running.
<eli5>
Apache is run in forking mode - for each PHP request there is an apache process in the server. So, if a site makes 10 requests in parallel, there are 10 apache processes running. These 10 apache processes have to live within the 2GB server you created above.Each of these processes can be doing simple to very complex things. Maybe one is just a healthcheck.php, do_simple_thing.php or do_complex_things.php . The php.ini memory_limit (which is 128MB by default) is the max that the apache process can take. Note that healthcheck can be just 1MB, do_simple_thing can be 50MB and we can have 30 of these concurrently, but just one do_complex_thing with 128MB. Basically, all sorts of combinations can exist as long as < 2GB. It depends on the app.
</eli5>I was originally trying to say that you cannot map 2GB to the app's max task memory limit. These have to be configured by the app author / cloudron sysadmin because this depends on the app and also how you have configured in apache.
-
@marcusquinn said in Set php.ini memory allocation to match Cloudron memory allocated:
Install the Query Monitor Plugin in Wordpress and look at the output before and after adding this setting and restarting the app, and you'll see what I mean.
Thanks. Will try for sure.
-
@girish said in Set php.ini memory allocation to match Cloudron memory allocated:
@micmc If it helps: setting memory limit for an app (at the Cloudron level) is like creating a virtual server with that much memory. So, if you allocate 2GB, it's like creating a 2GB server. Inside this 2GB server, there is apache running.
Wow, that's amazing!
And, with the rest of the explanation, it makes it more clear of how this works and how we can better know what we are doing while trying to cope with apps' memory.