Apache httpd process be killed by kernel oom

apache-2.2oom

some apache httpd process's memory and cpu usage too high, be killed by kernel, but I don't know why httpd use such many memory. I need some method to analyse or some method to reproduct.

some message about the apache and syslog

Server version: Apache/2.2.34 (Unix)
Server built:   Aug 17 2017 15:49:40

syslog message

Oct 19 15:28:20 kernel: httpd invoked oom-killer: gfp_mask=0x280da, order=0, oom_adj=0, oom_score_adj=0

Oct 19 15:28:20  kernel: httpd cpuset=/ mems_allowed=0-1

Oct 19 15:28:20  kernel: Pid: 7446, comm: httpd Not tainted 2.6.32_1-12-0-0 #1

Oct 19 15:28:20  kernel: Call Trace:

Oct 19 15:28:20  kernel:  [<ffffffff8108acf6>] ? dump_header+0x7c/0x187

Oct 19 15:28:20  kernel:  [<ffffffff8108b24b>] ? oom_kill_process+0x6c/0x17b

Oct 19 15:28:20  kernel:  [<ffffffff8108b784>] ? out_of_memory+0x32e/0x392

Oct 19 15:28:20  kernel:  [<ffffffff8108f6ce>] ? __alloc_pages_nodemask+0x694/0x7ff

Oct 19 15:28:20  kernel:  [<ffffffff810b60ac>] ? alloc_pages_vma+0x136/0x152

Oct 19 15:28:20  kernel:  [<ffffffff8109f281>] ? handle_pte_fault+0x16f/0x6f0

Oct 19 15:28:20  kernel:  [<ffffffff810033ee>] ? apic_timer_interrupt+0xe/0x20

Oct 19 15:28:20  kernel:  [<ffffffff813c5f70>] ? do_page_fault+0x444/0x46b

Oct 19 15:28:20  kernel:  [<ffffffff810a7984>] ? do_mremap+0x338/0x450

Oct 19 15:28:20  kernel:  [<ffffffff813c389f>] ? page_fault+0x1f/0x30

httpd ps img

Out of memory: Kill process 7446 (httpd) score 422 or sacrifice child

Killed process 7446, UID 500, (httpd) total-vm:922728068kB, anon-rss:28228104kB, file-rss:88kB

Best Answer

This means is that a request to allocate X amount of memory failed. So the Kenrel invoked the OOM killer which will terminates the highest memory consuming applications. System is out of physical and/or swap memory. What can be used as temporary fix, is to increase your swap size, till getting more RAM modules or capacity added to your server.

Also you most likely have configured Apache with mpm_prefork as an Apache module. This setup is slow and not thread safe. Modern web server setups use Apache with mpm_event. This will give you better performance, without eating up all your memory.