dunglas / frankenphp

🧟 The modern PHP app server
https://frankenphp.dev
MIT License
6.36k stars 203 forks source link

Too less information about `memory_limit` #846

Open ben221199 opened 1 month ago

ben221199 commented 1 month ago

Describe you feature request

Is your feature request related to a problem? Please describe. I see some people here talking about memory_limit. Some of them use -1. Mine is by default set to 128M. At the moment I don't see any information about it on the website/documentation or in this repository. The memory_limit is a limit per request. Does this mean that it is the maximum memory for a worker too, because it is a long running request. What is the best value for it in production? What is the best value for it in a Docker container (maybe in combination with a Docker container memory limit)? Also, wouldn't it be nice if we can set it with an environment variable out of the box (e.g. PHP_MEMORY_LIMIT or PHP_WORKER_MEMORY).

Describe the solution you'd like I want memory_limit covered in the documentation. Possibly I want to be able to set it using a environment variable without having to do much myself.

Describe alternatives you've considered For now I consider setting memory_limit to -1 in production using a .ini file. I limit my Docker container to 384 MB or 512 MB.

dunglas commented 1 month ago

I'll add some docs but it works "as expected". The limit is per request/worker. If it is reached, the worker restarts and an error is logged.

You can use ini_set('memory_limit', 'value'); to change the limit dynamically (as usual), the limit is automatically reset to the one defined in php.ini after the handling of each request.