• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved Have high CPU/memory usage? Read this!

Nikolay.

Silver Pleskian
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):
BaseDir "/usr/local/psa/var/health/data"
#TypesDB "/etc/sw-collectd/types.db"
FQDNLookup true
Hostname localhost
Interval 300
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.
 
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:
This looks like an interesting sript. Is there a 1...2...3 step article for downloading and installing it?
 
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.
 
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.
 
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?
 
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?

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.
 
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 ;)
 
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?
 
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.
 
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.

Any idea how to make it work with Wordpress??
 
Back
Top