Using Twitteroauth causes error(12) fork: Cannot allocate memory
Using Twitteroauth causes error(12) fork: Cannot allocate memory
I have Centos 5.5 running on a VPS - I have upgraded to PHP v5.2.14 with Zend Engine v2.2.0 and eAccelerator v0.9.6.1 installed.
My website runs fine, except when I attempt to use some code I have written to update twitter statuses through twitteroauth (their latest API for communicating with twitter).
The code works and is proven to update the status (it sends a maximum of 3 status messages), using CURL to communicate with the twitter engine
However, whenever I run this particular code, I get a mass of error messages in my error_log for example:
[Sun Nov 28 20:35:04 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:14 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:24 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:34 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:44 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:54 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:04 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:14 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:24 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:34 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:44 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:55 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:05 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:15 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:25 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:35 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:45 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:55 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
It is odd that this is once every 10 seconds.
On some occasions, the website still works after this, but on many ocassions, I have no option but to reboot the VPS.
Any suggestions as to what may be causing this issue?
Rich
My website runs fine, except when I attempt to use some code I have written to update twitter statuses through twitteroauth (their latest API for communicating with twitter).
The code works and is proven to update the status (it sends a maximum of 3 status messages), using CURL to communicate with the twitter engine
However, whenever I run this particular code, I get a mass of error messages in my error_log for example:
[Sun Nov 28 20:35:04 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:14 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:24 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:34 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:44 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:35:54 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:04 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:14 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:24 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:34 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:44 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:36:55 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:05 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:15 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:25 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:35 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:45 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
[Sun Nov 28 20:37:55 2010] [error] (12)Cannot allocate memory: fork: Unable to fork new process
It is odd that this is once every 10 seconds.
On some occasions, the website still works after this, but on many ocassions, I have no option but to reboot the VPS.
Any suggestions as to what may be causing this issue?
Rich
-
- Posts: 10642
- Joined: 2005/08/05 15:19:54
- Location: Northern Illinois, USA
Using Twitteroauth causes error(12) fork: Cannot allocate me
Have your VPS supplier give you more memory.
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
I am not sure that is the issue - surely if a PHP process cannot fork due to lack of memory, the server should not need to be rebooted in any case?
Besides the available memory is 8GB and under normal processes my website uses only around 700MB - I can't believe that oaauth to twitter to update a status would use another 7GB !!
What I have noticed is that the CPU usage is normally around 39% user, 14% kernel, 0% IO, 46% idle, but when I call the code to update the twitter feed, this can increase to around 73% user, 21% kernel, 0% IO, 6% idle
Open to more ideas - maybe something in the settings as to how much memory can be used by a process (no idea where to find that)
Besides the available memory is 8GB and under normal processes my website uses only around 700MB - I can't believe that oaauth to twitter to update a status would use another 7GB !!
What I have noticed is that the CPU usage is normally around 39% user, 14% kernel, 0% IO, 46% idle, but when I call the code to update the twitter feed, this can increase to around 73% user, 21% kernel, 0% IO, 6% idle
Open to more ideas - maybe something in the settings as to how much memory can be used by a process (no idea where to find that)
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
Please post the output from
[code]
grep memory_limit /etc/php.ini
[/code]
[code]
grep memory_limit /etc/php.ini
[/code]
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
grep memory_limit /etc/php.ini returns the following:
memory_limit = 128M
memory_limit = 128M
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
And how many apache processes are running when you get this error?
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
It jumps from 37 to 67 when I launch the call to twitteroauth. However, memory usage never seems to creep above 1GB.
Oddly the running processes take a while to close back down to the 37 level.
It is hard to tell how many processes are running when I get the error per se, as at that stage, the server is totally unresponsive and has to be rebooted!
More useful may be the CPU load at around the time:
CPU load averages 4.66 (1 min) 5.18 (5 mins) 2.32 (15 mins)
CPU usage 77% user, 22% kernel, 0% IO, 1% idle
Oddly the running processes take a while to close back down to the 37 level.
It is hard to tell how many processes are running when I get the error per se, as at that stage, the server is totally unresponsive and has to be rebooted!
More useful may be the CPU load at around the time:
CPU load averages 4.66 (1 min) 5.18 (5 mins) 2.32 (15 mins)
CPU usage 77% user, 22% kernel, 0% IO, 1% idle
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
67 * 128MB = 8576MB
It's right.
How much swap space do you have defined? I'd look at trying to reduce that php.ini setting to see if you can fit into 8GB. Also what do you have for these settings:
[code]
# find /proc -name "*commit*"
/proc/sys/vm/overcommit_ratio
/proc/sys/vm/overcommit_memory
# cat /proc/sys/vm/overcommit_memory /proc/sys/vm/overcommit_ratio
0
50
[/code]
It's right.
How much swap space do you have defined? I'd look at trying to reduce that php.ini setting to see if you can fit into 8GB. Also what do you have for these settings:
[code]
# find /proc -name "*commit*"
/proc/sys/vm/overcommit_ratio
/proc/sys/vm/overcommit_memory
# cat /proc/sys/vm/overcommit_memory /proc/sys/vm/overcommit_ratio
0
50
[/code]
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
I get the same output:
# find /proc -name "*commit*"
/proc/sys/vm/overcommit_ratio
/proc/sys/vm/overcommit_memory
# cat /proc/sys/vm/overcommit_memory /proc/sys/vm/overcommit_ratio
0
50
I have reduced the php.ini setting to 96MB and 64MB, but still get the same problem - what I don't quite understand is that memory usage stays below 1GB which suggests that the PHP code is not using all of the memory available.
# find /proc -name "*commit*"
/proc/sys/vm/overcommit_ratio
/proc/sys/vm/overcommit_memory
# cat /proc/sys/vm/overcommit_memory /proc/sys/vm/overcommit_ratio
0
50
I have reduced the php.ini setting to 96MB and 64MB, but still get the same problem - what I don't quite understand is that memory usage stays below 1GB which suggests that the PHP code is not using all of the memory available.
Re: Using Twitteroauth causes error(12) fork: Cannot allocate memory
I just had a quick google and found this illuminating thread [url=http://www.webhostingtalk.com/showthread.php?t=682317]here[/url] which talks about how the output from free does not reflect what is available to your VPS and gives some other things to check to see how much resource you actually have available.