服务器上的Apache Django OOM与4GB内存

我在Ubuntu Linode上运行一个生产Django站点,带有4GB内存。 主要进程是Apache2,MongoDB,Memcache,PostgreSQL,Tomcat6和Redis。 Apache OOM每天大约10次。 我多次调整了apache2.conf中的值,并没有发现任何效果。 请求数量和内存峰值或请求和内存峰值之间没有明显的相关性。 我说“spikes”,因为通常Apache只消耗很less的内存,然后在一秒钟内突然跳到3.5GB并被内核杀死。 使用JMeter(负载testing软件)我无法人为地触发尖峰,正常情况下负载下的内存消耗非常低且稳定。

内存使用的24小时图(来自Linode Longview): http : //i.imgur.com/ysIYe8l.png

这也看起来像内存使用也在缓慢攀升。

从系统日志:

kernel: apache2 invoked oom-killer: ... kernel: 11705 total pagecache pages kernel: 5472 pages in swap cache kernel: Swap cache stats: add 76719087, delete 76713615, find 92563708/94246314 kernel: Free swap = 0kB kernel: Total swap = 2097148kB kernel: 1050623 pages RAM kernel: 43278 pages reserved kernel: 788996 pages shared kernel: 999768 pages non-shared ... kernel: [ pid ] uid tgid total_vm rss nr_ptes swapents oom_score_adj name kernel: [ 3709] 1000 3709 3706586 889237 7117 464598 0 apache2 ... kernel: Killed process 3709 (apache2) total-vm:14826344kB 

当前apache2.conf:

 Timeout 30 KeepAlive Off <IfModule mpm_prefork_module> StartServers 3 MinSpareServers 2 MaxSpareServers 5 MaxClients 10 MaxRequestsPerChild 1000 </IfModule> 

切换到Nginx不是一个选项。 大多数情况下,OOM不会杀死系统,但每隔几个星期它都会重新启动服务器。 A:这可能是什么原因? B:我还没有做什么来诊断真正的原因?

你有Django应用程序运行? 这是其中之一。

不知道你如何设置它我投钱,你已经build立,使Python / Django的运行时与Apache共享内存空间。 内存使用正在这里被混淆。