Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Apache using up too much CPU.

Discussion in 'Workarounds and Optimization' started by desiguru, Nov 2, 2010.

  1. desiguru

    desiguru Well-Known Member

    Aug 27, 2008
    Likes Received:
    Trophy Points:
    Hey guys,

    I have some major problem with my server. Up until last week, it was working really good but lately I have to wake up in the middle of the night to restart the server.

    I have tried tweaking a lot of things but not sure where to go now. I'm assuming the real problem is in mySQL but not sure what configuration I should put.

    Can someone please post/guide me on how to tweak Apache and MySQL please. Many thanks.
  2. GaryT

    GaryT Well-Known Member

    May 19, 2010
    Likes Received:
    Trophy Points:
    On the time it goes bad you should check the connections to the apache, It could be possible that you may be under a Dos attack which can crash the server.

    Check apache error logs:

    Check apache connections:

    Check All connections:

    Go through your apache log and check whats gone on at the time of the server crash.

    For more help you should post the stats of your machine, Followed by your my.cnf so people can have a better idea on helping you tweek such things.

    It could be possible that your running out of memory or such, Infact it could be hundreds of things its just the matter of finding it.
  3. cPanelTristan

    cPanelTristan Quality Assurance Analyst Staff Member

    Oct 2, 2010
    Likes Received:
    Trophy Points:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    You could see what's happening on the machine before it has to be restarted by logging the processes and memory details using script. This is a light weight script that pulls details and logs them each minute. It can then be used when the server reboots to see the last logs information for the 5-10 minutes before it rebooted.

    To grab and run the script, you could use the following commands:

    cd /
    chmod +x
    nohup ./ &
    At that point, ctrl+c after it starts, and it will start logging to system-snapshot folder location for log files every minute. When the server reboots, it will stop logging as the script will not restart on boot (you can always run the "nohup ./ &" command again at any point after the reboot to start the logging again).
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  4. desiguru

    desiguru Well-Known Member

    Aug 27, 2008
    Likes Received:
    Trophy Points:
    Thank you for your suggestions. Here are my initial results

    netstat -nt | grep :80 | wc -l
    877 (This was initially 1300+ but after finding 200 connections open from a single IP I had to block it and thet brought down the number a lot))
    Also this thing is always using my CPU a lot how can I fix it?

    /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/etc/httpd/logs/mysqld.err --pid-file=/var/lib/mysql/

    Here is my my.cnf values

    set-variable = max_connections=600
    # Connection timeout
    connect_timeout                   = 20
    # Timeout for inactive connections
    wait_timeout                      = 60
    # Network buffer length (I think this is the linux default)
    net_buffer_length                 = 16K
    log-error                         = /etc/httpd/logs/mysqld.err
    binlog_cache_size                 = 2M
    table_cache                       = 6588
    join_buffer_size                  = 320M
    tmp_table_size                    = 512M
    sort_buffer_size                  = 128M
    thread_cache_size                 = 6
    max_heap_table_size               = 320M
    query_cache_size                  = 312M
    key_buffer_size                   = 128M

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice