1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Resolved Have high CPU/memory usage? Read this!

Discussion in 'Plesk 11.x for Linux' started by Nikolay., Jul 1, 2012.

  1. Nikolay.

    Nikolay. Silver Pleskian

    17
    35%
    Joined:
    Jul 1, 2012
    Messages:
    844
    Likes Received:
    2
    OK, lately I saw a couple of threads on this forum reporting problems with high CPU and/or memory usage. Naturally, this can be caused by a multitude of reasons and usually requires investigation. I decided to post a couple of common reasons and solutions here (this was written with Plesk 11 for Linux in mind, but may be applicable to other versions and products as well, YMMV however).

    DISCLAIMER: this information is provided as is and without warranty of any kind (including promise of usefulness or not being harmful). Therefore think first and use at your own risk later.

    1) Leap second

    A day or so ago a leap second was introduced. This caused some... disturbance on a number of Linux systems. Some kernels just crashed or hung. Other applications started to misbehave, e.g. consume a lot of CPU.

    Symptoms: CPU usage of your Java applications or MySQL server (other applications might be susceptible as well) have grown significantly lately.

    Solution: is pretty simple. You just need to remove leap second flag from the system. Running this should suffice (you don't need to restart other services after that):

    # /etc/init.d/ntpd stop; date -s "`date`"; /etc/init.d/ntpd restart

    Alternatively you could just restart the machine. It seems to help too.

    Restarting the affected services alone, however, will not fix the problem.

    2) PHP sessions cleanup

    On some systems (I believe, rpm-based only) in Plesk 10 PHP sessions cleanup was not working properly. This was fixed in Plesk 11 (a proper periodic cleanup task was added). Therefore if you've just upgraded from a lower Plesk version you might notice at times a significant CPU and memory load (provided your sessions directory is clogged up).

    Symptoms: 'find' and 'fuser' processes are consuming a lot of CPU time and/or memory.

    Solution: is rather straightforward (and relatively painless, if you can afford it). Just purge all your PHP sessions. First you need to find where your sessions are stored. For that find your client php.ini file(s) which are usually in something like /etc/php5/*/php.ini or /etc/php.ini. Than find 'session.save_path' directive there. If you actually have this problem, it most probably will contain either '/var/lib/php/session' or '/var/lib/php5', let's assume this is a value of 'sessionSavePath' shell variable. Then to purge all sessions:

    # [ -n "${sessionSavePath}" ] && rm -f ${sessionSavePath}/* || echo "Set sessionSavePath first"

    Take care not to remove the directory itself. Also I advice against removing Plesk cleanup task (as somebody else might advice to do), since this will just slow down your server and lead to increased disk space consumption in the long run.

    3) sw-collectd data collection interval is too low

    In previous Plesk versions sw-collectd data collection interval was not set explicitly. By default it is 10 or 0 (can't remember right now which one), the latter means "collect data as often as you can". This, obviously, usually results in noticeable CPU and other systems' load.

    In Plesk 11 (on clean installations, i.e. not upgrades) this interval is set to 300 (5 minutes). However, upgraded installations will have their interval value unchanged. There is a serious reason for that: simply changing interval value in configuration file and restarting sw-collectd may lead to unexpected behavior. E.g. on my test installation just increasing this value led to rrdtool showing only either zero or NaN values.

    Symptoms: sw-collectd process consumes a lot of CPU time and/or other resources.

    Solution: properly set data collection interval to some reasonably high value. E.g. 300 seconds. I'm not entirely sure (so don't quote me on this), but I doubt setting it to lower value brings any benefits now, since Health monitor module rereads resource usage values at this rate. Note that to safely increase the interval you must drop entire previous statistics.

    1. # /etc/init.d/sw-collectd stop
    2. Edit file /etc/sw-collectd/collectd.conf to include 'Interval 300' line at top level. Replace '300' with your desired interval in seconds. E.g. (relevant chunk of file, just to give you a context):
    3. Notice the BaseDir and Hostname directives in the configuration file. From them a path to the statistics storage is assembled. You have to remove any collected data:
            # rm -rf /usr/local/psa/var/health/data/localhost/*
    4. # /etc/init.d/sw-collectd restart

    Also, there is a KB for increasing the interval value here, even two, to be precise. They are both wrong, however.



    That's it for now. If I find other common reasons, I'll update the thread.

    If you try any of the solutions, please post whether it helped you or not. If not, post exact symptoms. Maybe somebody will be able to help you.
     
  2. ClassicVinyl

    ClassicVinyl New Pleskian

    10
    85%
    Joined:
    May 16, 2012
    Messages:
    11
    Likes Received:
    0
    Another Solution that Worked For Me - Block Fake Google Bots

    NOTE: I am using Plesk 10.4


    I took my CPU usage down from 80% - 140% (almost all the time) simply by blocking fake google bots and banning hostile spambots. These entities play havoc with system performance if they are not controlled.

    My CPU usage now hovers at a mere 10% and my sites and Plesk admin panel are lightning responsive. (I am on a UNIX box.) My MySQL cpu also dropped by a corresponding amount. I accomplished this by using an open source software package (for php) called Zbblock.

    While the post by the OP above may be helpful, it appears to address issues that may have developed only in recent days. My difficulties with high CPU usage go back several weeks, and for many here, several years.

    To obtain the Zbblock script, please visit this Website:

    http://www.spambotsecurity.com/

    NOTE: I do not in any way, shape or form represent the author of this software and have nothing whatsoever to do with the website above. Rather, I attempted every conceivable solution offered on the Parallels boards, and when none of them worked, I tried Zbblock. USE AT YOUR OWN RISK. I FOLLOWED THE DIRECTIONS AND THIS PRODUCT HAS WORKED BRILLIANTLY FOR ME. IT DOES NOT INTERACT WITH YOUR DATABASE, NOR DOES IT CHANGE ANY FILES IN YORU ROOT OR OTHER DIRECTORIES THAT ARE OUTSIDE THE ZBBLOCK DIRECTORY. THERE IS AN ACTIVE SUPPORT COMMUNITY FOR THE PRODUCT AT THE WEBSITE I CITED ABOVE.

    Search the website forum for ways to prevent fake googlebots from attacking your site. There is special code you add to two specific files in Zbblock. Search on "fake googlebots."

    For me, the results were instantaneous. There is a kill file that you can review after a few hours to see how many bots were banned. Mine filled up with thousands of entries in a very brief time.

    NOTE: This script does not ban authentic google robots. To be completely safe you can add a whitelist of genuine google bot IP addresses to the appropriate file.

    There is no need to alter your .htaccess file, which is NOT an effective way of banning IPs or bots in the first place.
     
    Last edited: Jul 2, 2012
  3. TobyP

    TobyP New Pleskian

    16
    35%
    Joined:
    Jan 30, 2011
    Messages:
    10
    Likes Received:
    0
    This looks like an interesting sript. Is there a 1...2...3 step article for downloading and installing it?
     
  4. Faris Raouf

    Faris Raouf Silver Pleskian Plesk Guru

    31
    30%
    Joined:
    Mar 15, 2009
    Messages:
    667
    Likes Received:
    17
    Thanks for your very useful post, particularly regarding the sw-collectd stats fix. I think this is going to help a lot of people and I really appreciate the time you took to post this.


    Interestingly, I'm getting some hilarious results after restarting a Plesk 10 (NOT 11) machine after following your additional tips on how to get the stats to work again after adjusting the Interval value. Again I emphasise this is Plesk 10, not 11. I'm only posting because the results are really hilarious and I thought it might brighten up someone's day. See the attached screen shot.
     
  5. MemoonaM

    MemoonaM Guest

    0
     
    Thanks for providing the solutions of this problem because it is a common problem with many people and I thought after reading this article many of them can took benefit from it.
     
  6. ClassicVinyl

    ClassicVinyl New Pleskian

    10
    85%
    Joined:
    May 16, 2012
    Messages:
    11
    Likes Received:
    0
    Yes, you can peruse the manual that comes with the .zip download.
     
  7. TobyP

    TobyP New Pleskian

    16
    35%
    Joined:
    Jan 30, 2011
    Messages:
    10
    Likes Received:
    0
    Applied To Each Website Independantly?

    presumably, from reading the forum, the ZB Block script has to be applied independantly to each website on the server?

    Bit of a pain if you are running dozens of websites and the script has updates etc?

    Is there a server wide alternative?
     
  8. ClassicVinyl

    ClassicVinyl New Pleskian

    10
    85%
    Joined:
    May 16, 2012
    Messages:
    11
    Likes Received:
    0
    I am running drupal, and because I can run dozens of websites off of one codebase installation, I am able to put a single zbblock install in the root and have it work for all sites that depend on that single codebase.

    Not sure if other CMS scripts work the same way.
     
  9. BorisJ

    BorisJ New Pleskian

    10
    35%
    Joined:
    Jun 12, 2012
    Messages:
    6
    Likes Received:
    0
    Hi,

    I'm new with Plesk Panel 11 and also in general. Can anyone please tell me where I could investigate why the CPU gets so high? In "Server Management -> Health Monitoring -> CPU" I can see just statistical data in graph, but not what process or file causes the problem. In last day I had like two spikes in CPU usage and like eight spikes in blocked processes - however I don't know how can I start to investigate the source of problems.

    I have additionally installed WatchDog, Firewall and Fail2Ban (also Health Monitoring which I already mentioned).

    Thanks ;)
     
  10. ClassicVinyl

    ClassicVinyl New Pleskian

    10
    85%
    Joined:
    May 16, 2012
    Messages:
    11
    Likes Received:
    0
    You can start by looking at your log files. There are literally hundreds of threads on these boards with solutions -- SSH commands for example to monitor in real time processor usage -- to your problem, I'd suggest doing some research. I am not using Plesk 11, but 10.4; has 11 come out in a final release?
     
  11. TobyP

    TobyP New Pleskian

    16
    35%
    Joined:
    Jan 30, 2011
    Messages:
    10
    Likes Received:
    0
    I switched php to fastcgi and that resolved my problem. I found a line to put through PUTTY ie. a manual change. But I think it can be done from the control panel. This forum is pretty helpful, I've yet to be the first to have had a problem and usually by the time I do someone else has resolved it and posted here.
     
  12. Red Paint

    Red Paint Basic Pleskian

    26
    23%
    Joined:
    Aug 19, 2009
    Messages:
    78
    Likes Received:
    1
    I just found this thread after experiencing high CPU load related to fuser.

    After some digging I also found a KB article which gave us the solution we needed: http://kb.parallels.com/en/119500, hope this helps someone else.
     
  13. Kingsley

    Kingsley Regular Pleskian

    21
    73%
    Joined:
    Dec 13, 2014
    Messages:
    473
    Likes Received:
    18
    Location:
    Nigeria
    Having same problem, mine is kinda cause by BOTS
     
  14. Kingsley

    Kingsley Regular Pleskian

    21
    73%
    Joined:
    Dec 13, 2014
    Messages:
    473
    Likes Received:
    18
    Location:
    Nigeria
    Any idea how to make it work with Wordpress??
     
Loading...