Cannot allocate memory: fork: Unable to fork new process?

◇◆丶佛笑我妖孽 提交于 2019-12-21 03:46:24

问题


We have our hosting in aws. Recently after moving our blog from wordpress to aws, we are experiencing noticeable delay in server response time. Mainly while accessing the blog. Below are the logs from the error_log file,

[Wed Feb 25 06:10:10 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 25 06:12:22 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 25 06:12:36 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 25 06:12:50 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 25 06:13:35 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[error] (12)Cannot allocate memory: fork: Unable to fork new process
[Wed Feb 25 06:27:14 2015] [error] (12)Cannot allocate memory: fork: Unable to fork new process

We increased the memory size from 256 to 512 mb in php.ini file. But, still the issue exist.

We also changed the KeepAlive as On. Still it doesn't resolve. Any suggestions / solutions would be of great help.


回答1:


I've face that problem either while hosting a java app with jenkins, mysql & tomcat on ubuntu on an vm of AWS.

First steps I used to solve the problem with restarting a vm.

AWS doesn't give swap memory on a harddrive by default, so you'd better to make it with your hands. How to do this you can find here. Need to mention: the solution with swap zone (have no idea why) haven't work for me, I had to create a swap file.

Good luck to you!




回答2:


I had same problem to fix it there is 2 options:

1- move from micro instances to small and this was the change that solved the problem (micro instances on amazon tend to have large cpu steal time)

2- tune the mysql database server configuration and my apache configuration to use a lot less memory.

tuning guide for a low memory situation such as this one: http://www.narga.net/optimizing-apachephpmysql-low-memory-server/ (But don't use the suggestion of MyISAM tables - horrible...)

this 2 options will make the problem much much less happening .. I am still looking for better solution to close the process that are done and kill the ones that hang in there .




回答3:


Changed Apache's prefork MPM into the httpd.conf These are the values I ended up using:

StartServers 1

MinSpareServers 1

MaxSpareServers 5

ServerLimit 16

MaxClients 16

MaxRequestsPerChild 0

ListenBacklog 100

Then, try to desactivate some modules php with sudo a2dismod name_of_module



来源:https://stackoverflow.com/questions/28715545/cannot-allocate-memory-fork-unable-to-fork-new-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!