How to Debug and Fix Out of Memory (OOM) Killer terminating PHP-FPM pool workers in Modern WooCommerce Applications
Understanding the OOM Killer and PHP-FPM
The Out-Of-Memory (OOM) Killer is a crucial component of the Linux kernel designed to reclaim memory when the system is under severe memory pressure. It achieves this by selecting and terminating processes that are deemed to be consuming excessive amounts of memory. In the context of a modern, high-traffic WooCommerce application, PHP-FPM worker processes are frequent targets of the OOM Killer, especially during peak loads or when memory leaks are present. This leads to intermittent site outages, lost requests, and a frustrating user experience. Debugging this requires a systematic approach, starting with identifying the culprit and then implementing targeted solutions.
Identifying OOM Killer Events
The first step is to confirm that the OOM Killer is indeed the cause of your PHP-FPM worker terminations. The most reliable place to find this information is the system logs. On most Linux distributions, this will be in /var/log/syslog or /var/log/messages. You can use grep to filter for relevant messages.
Look for lines containing “Out of memory” and “killed process”. The output will typically include the process ID (PID), the process name, and the amount of memory it was consuming. Pay close attention to the process name, which should clearly indicate a PHP-FPM worker (e.g., php-fpm: pool www).
Here’s a typical log entry you might encounter:
Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] Out of memory: Kill process 9876 (php-fpm) score 1234, not enough free std: 123456kB, swap free: 123456kB Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] oom_kill_allocating_task: 123456 callbacks suppressed Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] php-fpm invoked oom-killer: gfp_mask=0x100d0, order=0, oom_score_adj=0 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] CPU: 0 PID: 9876 Comm: php-fpm Not tainted 5.4.0-91-generic #102-Ubuntu Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] Hardware name: Supermicro X11SSH-F/X11SSH-TF, BIOS 2.0 08/10/2017 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] Call Trace: Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] dump_stack+0x6d/0x8b Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] dump_stack_lvl+0x49/0x5f Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] out_of_memory+0x1f2/0x400 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] __alloc_pages_nodemask+0x11d/0x330 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] alloc_pages_current+0x10/0x20 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] __kmalloc_track.isra.56+0x24/0x50 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] kmalloc_array_node+0x1a/0x30 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] kvcalloc+0x1a/0x30 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] __request_module+0x100/0x1c0 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] load_module+0x13f/0x260 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] __request_module+0x11/0x1c0 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] sys_init_module+0x160/0x2a0 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] __x64_sys_finit_module+0x1e/0x30 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] do_syscall_64+0x57/0xb0 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] entry_SYSCALL_64_after_hwframe+0x44/0x49 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] RIP: 0010:0xffffffffc0a12345 Oct 26 10:30:01 your-server-hostname kernel: [123456.789012] Code: 48 8b 05 12 34 56 78 48 85 c0 74 12 48 89 c5 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48 89 c7 48 83 c4 20 5d c3 48