#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2

    Apache error log (newbie)


    Hi all,

    Can anyone please tell me in /var/log/apache2/error.log does an error correspond to a particular browser request so for example

    [Wed May 15 07:09:27 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Wed May 15 07:09:38 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    Would this mean that at 07:09:27 and at 07:09:38 a particular page failed to load? If so what message would the browser give?

    Any ideas please why my errors below seem to be precisely every 10 seconds?

    Thanks...



    [Thu May 16 03:05:10 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:05:20 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:05:30 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:05:40 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:05:50 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:00 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:10 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:20 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:30 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:40 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:06:50 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:07:00 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    [Thu May 16 03:07:10 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,143
    Rep Power
    9398
    It's not tied with a specific request.

    How's the memory usage on the machine?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    India
    Posts
    6
    Rep Power
    0
    yea, its memory restrictions within the server or with the PHP handler. Can you confirm the server does have enough memory?.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2
    Thanks for replies. I generally have plenty of free memory but I get these occasional spikes in memory use. I know that one cause of this is the 5GB back ups that are scheduled for twice a week. I think this back up takes 2 or 3 hours and during this I can get memory errors for maybe 20 minutes. I am not sure yet whether this is the only cause or if there is also something else causing these memory errors.

    Anyway back to Apache - if my error (random example)...
    Code:
    [Wed May 15 07:09:27 2013] [error] (12)Cannot allocate memory: fork: Unable to fork new process
    ...does not correspond to a particular browser request at 07:09 then what does it correspond to or I mean how is the Apache error log generated?

    Thanks...
  8. #5
  9. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,143
    Rep Power
    9398
    It's probably Apache trying to fire up child workers, which it does in the background so it doesn't have to do it before fulfilling a request.

    This backup thing you describe sounds like the culprit. After all, the errors only happen while the backup is running.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Location
    Brooklyn, NYC
    Posts
    34
    Rep Power
    3
    Disable the mod_python and try to check, is the problem again comes back
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2
    Originally Posted by requinix
    It's probably Apache trying to fire up child workers, which it does in the background so it doesn't have to do it before fulfilling a request.
    OK thanks. Here htop shows nearly thirty Apache processes each using about 1.6% of my 2.5 GB RAM. Does this correspond to the number of browsers making requests at this particular time?

    Thanks...
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    India
    Posts
    6
    Rep Power
    0
    Yes exactly, there may be more apache processes which are less intensive down the table too. By the way what PHP handler do you have?.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2
    Originally Posted by kevincheri

    By the way what PHP handler do you have?.
    info.php says Server API: Apache 2.0 Handler


    Yes exactly, there may be more apache processes which are less intensive down the table too.
    OK so htop says that the first Apache process is using 1.8% of my memory so 1.8% x 2560 MB = 46.08 MB - so one visitor browser is using 46.08 MB? This seems like a lot. So anyway would there be a minimum amount of memory required to run an Apache process ie to load a particular page and then this might increase according to the content of the page?

    Thanks...
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2
    Originally Posted by requinix
    It's probably Apache trying to fire up child workers, which it does in the background so it doesn't have to do it before fulfilling a request.

    This backup thing you describe sounds like the culprit. After all, the errors only happen while the backup is running.
    Well I said I wasn't sure yet and I can now see that there is a separate problem ie not caused by the back up. Normally my memory stays below about 20% and I can see in htop there are about 10 Apache processes running. If this corresponds to 10 visitors this sounds about right (the website gets about 700 visits per day). But occasionally the memory goes crazy for several hours at a time ie gradually increasing to over 98%. I can see in htop at these times that I have 40 - 50 apache processes running each using about 1.7% of my RAM. But looking at my visitor analytics I can see there is no corresponding traffic spike to explain this increase in Apache processes.

    Any ideas please about these mystery Apache processes?

    Thanks
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    Do you have access to your apache2.conf file?

    If you do, look for this section (your numbers will most likely be different)
    Code:
    <IfModule mpm_prefork_module>
        StartServers                     5
        MinSpareServers                5
        MaxSpareServers              10
        MaxClients                      150
        MaxRequestsPerChild          0
    </IfModule>
    Change your MinSpareServers and MaxSpareServers numbers to something lower (like MinSpareServers 5 ...and MaxSpareServers 20) , then, restart Apache.

    This would keep apache from creating those 30 -40 extra processes and limit it to whatever you set...hopefully solving your memory usage issue.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    46
    Rep Power
    2
    Originally Posted by DonR
    Do you have access to your apache2.conf file?

    If you do, look for this section (your numbers will most likely be different)
    Code:
    <IfModule mpm_prefork_module>
        StartServers                     5
        MinSpareServers                5
        MaxSpareServers              10
        MaxClients                      150
        MaxRequestsPerChild          0
    </IfModule>
    Change your MinSpareServers and MaxSpareServers numbers to something lower (like MinSpareServers 5 ...and MaxSpareServers 20) , then, restart Apache.

    This would keep apache from creating those 30 -40 extra processes and limit it to whatever you set...hopefully solving your memory usage issue.

    @ DonR - here are the current values - so it looks like MinSpareServers and MaxSpareServers are already low:

    Code:
    cat /etc/apache2/apache2.conf
    <IfModule mpm_prefork_module>
    StartServers       2
    MinSpareServers    3
    MaxSpareServers    3
    ServerLimit        128
    MaxClients         128
    MaxRequestsPerChild   1000
    </IfModule>
    Thanks...

IMN logo majestic logo threadwatch logo seochat tools logo