Fly Laravel image does not seem to respect memory limit

Hi there!

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?

CC @fideloper-fly considering you wrote the Dockerfile :slight_smile:

Hm okay, I know what’s happening.

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 :slight_smile:

Thanks for the heads up, I’ll see about taking a look at that.

Can you try using php artisan queue:work --memory=1024 as the queue process in the meantime?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.