govCMS / scaffold-tooling

6 stars 17 forks source link

Ability to increase PHP memory limit in CLI mode. #251

Closed barbun closed 1 year ago

barbun commented 1 year ago

Issue

Some projects require more PHP memory when performing drush cron tasks. (e.g. indexing large files). Drush memory limit is bound to PHP's memory limit, however, increasing PHP memory wholesale can introduce problems with multiple php-fpm workers.

Proposed solution

Add ability to increase PHP memory in CLI mode only.

tobybellwood commented 1 year ago

There's already a PHP_MEMORY_LIMIT variable for that? https://github.com/uselagoon/lagoon-images/blob/main/images/php-fpm/00-lagoon-php.ini.tpl#L5

steveworley commented 1 year ago

@tobybellwood as far as I can tell that impacts both CLI and FPM pods (eg. if we bump to 800M to complete core cron then requests can use up to 800M as well).

[vanilla-govcms9-beta]master@php:/app$ env | grep MEMORY
PHP_MEMORY_LIMIT=800M
[vanilla-govcms9-beta]master@php:/app$ php -i | grep memory_limit
memory_limit => 800M => 800M

and in the CLI pod

[vanilla-govcms9-beta]master@cli-drupal:/app$ php -i | grep memory
memory_limit => 800M => 800M

To limit the impact of a high memory requirement for CLI tasks (eg. search_api_attachments indexing large documents), I would prefer if we didn't have the memory limit so high on requests. We did have an issue where a site had an elevated PHP memory limit and was able to cripple nodes due to the resource requests it was making (there was a memory leak causing each proc to exhaust its allocation and hold requests).