Sample Header Ad - 728x90

OOM invoked regularly by PHP-FPM

0 votes
0 answers
716 views
I'm using EC2 instance t4g.micro which is arm64, with 1gb ram of the latest ubuntu. I'm using nginx with PHP-FPM for upload and convert pictures using latest image.intervention with GD. My PHP_FPM configuration:
pm = static
pm.max_children = 1
pm.max_requests = 300
And php.ini:
max_execution_time = 5
memory_limit = 100M
opcache.enable = 1
opcache.jit_buffer_size = 50M
opcache.jit = 1255
And yet I keep on getting those messages from time to time on my syslog:
Out of memory: Killed process 510 (php-fpm8.3) total-vm:490452kB, anon-rss:273404kB, file-rss:2944kB, shmem-rss:3840kB, UID:1001 pgtables:708kB oom_score_adj:0
Out of memory: Killed process 510 (php-fpm8.3) total-vm:499780kB, anon-rss:282508kB, file-rss:2944kB, shmem-rss:3968kB, UID:1001 pgtables:720kB oom_score_adj:0
Out of memory: Killed process 20481 (php-fpm8.3) total-vm:495800kB, anon-rss:272472kB, file-rss:2944kB, shmem-rss:3456kB, UID:1001 pgtables:708kB oom_score_adj:0
Out of memory: Killed process 24725 (php-fpm8.3) total-vm:465556kB, anon-rss:247920kB, file-rss:2944kB, shmem-rss:1664kB, UID:1001 pgtables:648kB oom_score_adj:0
Out of memory: Killed process 24732 (php-fpm8.3) total-vm:458888kB, anon-rss:240892kB, file-rss:2816kB, shmem-rss:3456kB, UID:1001 pgtables:624kB oom_score_adj:0
Out of memory: Killed process 24739 (php-fpm8.3) total-vm:458280kB, anon-rss:240372kB, file-rss:2816kB, shmem-rss:3456kB, UID:1001 pgtables:628kB oom_score_adj:0
Sometimes it cause my instance to not respond at all ,not even to SSH, and the CPU reach to 60% precent on AWS monitor and stay there till I manually click on restart instance several times which might cause hard restart. My php script is simple, takes post image file, convert it and save, using image.intervention functions only, no error are thrown. The OOM killed might happened once a week.. I tried tuning my configuration to the lowest possible, decreasing pm.max_requests is not a solution for me. All I want is to avoid OOM intervention, control php to kill request that absorb to much memory before it crushes PHP-FPM. I already modified PHP-FPM service to restart itself on failure, but sometimes it crushes the whole ubuntu system with high CPU and makes it not responding to anything which is what I must avoid in the first place. Could it be a leak on php arm specific instance that x86 might avoid? How can I stable my instance?
Asked by user24198409 (1 rep)
Apr 11, 2024, 03:16 PM