We are running into some memory problems on a Symfony app using fideloper/fly-laravel:8.2. One process reached 15GB of memory usage. When looking into php settings, I see that ini_get('memory_limit') === -1. I have this in my fly.toml:
[env]
PHP_MEMORY_LIMIT = "1024M"
I was expecting this to make sure my processes never grow above 1GB, but it doesn’t seem to do this. Any idea?
The CLI uses a different php.ini, makes sense. /etc/php/8.2/cli/php.ini has configured:
; Maximum amount of memory a script may consume
; https://php.net/memory-limit
memory_limit = -1
So, commands like php artisan queue:work (or in our specific case php bin/console messenger:consume) still has the freedom to consume infinite memory. Any idea how I can still impose a limit on this? Few things I can do:
I could take this cli/php.ini file, move it into our codebase, modify it and cp it in the Dockerfile
Do something with sed to modify the php.ini.
I am wondering if someone knows a simpler approach