server health apache CPU usage

Community support for Plesk, CPanel, WebMin and others with insight from two of the founders of Plesk. Ask for help here! No question is too simple or complicated. :-)
mist_firefly
Forum User
Forum User
Posts: 60
Joined: Mon Jul 23, 2012 5:22 am
Location: Salisbury

server health apache CPU usage

Unread post by mist_firefly »

We have a high Apache CPU usage on our plesk . the percent is 45,7%

Why could this happen and what can I do when high CPU usages shows ?

Should I restart apache? Would that affect anything on the server for our clients? (I'm still new so not sure what does affect domains and the server and what not)

Thanks
srpurdy
Forum Regular
Forum Regular
Posts: 110
Joined: Sat Jan 21, 2012 6:37 pm
Location: Canada

Re: server health apache CPU usage

Unread post by srpurdy »

If you restart apache it should make sites go offline for a split second it will likely not even be noticed.

On occasion this is needed, but you can also restart apache gracefully which makes sure active tasks get completed before it restarts itself.

So yes it will effect things, but unless apache fails to restart it will only be for 1 second at most. But don't be worried about that. Everytime you add a domain in plesk apache has to be restarted. So this is normal operations for a webserver. :)

It's unlikely though this will solve your cpu issue unless a task has crashed for some reason. You can try to restart, but if the problem continues you may want to post some apache settings. Also if your running PHP through apache? This could be the reason why apache has high cpu usage. It's advised to run PHP under fast-cgi in plesk. As running under apache (mod_php) is not secure, and causes permission issues.
prupert
Forum Regular
Forum Regular
Posts: 573
Joined: Tue Aug 01, 2006 2:45 pm
Location: Netherlands

Re: server health apache CPU usage

Unread post by prupert »

srpurdy wrote:If you restart apache it should make sites go offline for a split second it will likely not even be noticed.

On occasion this is needed, but you can also restart apache gracefully which makes sure active tasks get completed before it restarts itself.

So yes it will effect things, but unless apache fails to restart it will only be for 1 second at most. But don't be worried about that. Everytime you add a domain in plesk apache has to be restarted. So this is normal operations for a webserver. :)
It can have some effect depending on the type of web sites and web application you are hosting on your server. We have several clients that will panick once the web server goes offline, even for some seconds. Also, if only one process is causing trouble why would you want to restart the whole web server? You could simply investigate the one process and even kill this one process if you believe it is causing trouble.

Plesk only restarts Apache httpd gracefully. It is not normal operations for a web server to be non-gracefully restarted regularly.
It's unlikely though this will solve your cpu issue unless a task has crashed for some reason. You can try to restart, but if the problem continues you may want to post some apache settings.
You could investigate the process (using strace, lsof etc.) to find out what the process is doing.

40 % cpu usage for a short period of time is not necessarily out of the ordinary. It all depends on what the impact on your server is.
Also if your running PHP through apache? This could be the reason why apache has high cpu usage. It's advised to run PHP under fast-cgi in plesk. As running under apache (mod_php) is not secure, and causes permission issues.
Running PHP under fast-cgi actually consumes more RAM. Apache mod_php is the most efficient way to run PHP code in Plesk. It is not necessarily insecure provided you have open_basedir configured and the hardened ASL PHP configuration. Permission issues can be resolved by changing permissions on certain files. Although not the most ideal or user-friendly option, this is not necessarily bad.
Lemonbit Internet Dedicated Server Management
srpurdy
Forum Regular
Forum Regular
Posts: 110
Joined: Sat Jan 21, 2012 6:37 pm
Location: Canada

Re: server health apache CPU usage

Unread post by srpurdy »

prupert wrote:
srpurdy wrote:If you restart apache it should make sites go offline for a split second it will likely not even be noticed.

On occasion this is needed, but you can also restart apache gracefully which makes sure active tasks get completed before it restarts itself.

So yes it will effect things, but unless apache fails to restart it will only be for 1 second at most. But don't be worried about that. Everytime you add a domain in plesk apache has to be restarted. So this is normal operations for a webserver. :)
It can have some effect depending on the type of web sites and web application you are hosting on your server. We have several clients that will panick once the web server goes offline, even for some seconds. Also, if only one process is causing trouble why would you want to restart the whole web server? You could simply investigate the one process and even kill this one process if you believe it is causing trouble.

Plesk only restarts Apache httpd gracefully. It is not normal operations for a web server to be non-gracefully restarted regularly.
It's unlikely though this will solve your cpu issue unless a task has crashed for some reason. You can try to restart, but if the problem continues you may want to post some apache settings.
You could investigate the process (using strace, lsof etc.) to find out what the process is doing.

40 % cpu usage for a short period of time is not necessarily out of the ordinary. It all depends on what the impact on your server is.
Also if your running PHP through apache? This could be the reason why apache has high cpu usage. It's advised to run PHP under fast-cgi in plesk. As running under apache (mod_php) is not secure, and causes permission issues.
Running PHP under fast-cgi actually consumes more RAM. Apache mod_php is the most efficient way to run PHP code in Plesk. It is not necessarily insecure provided you have open_basedir configured and the hardened ASL PHP configuration. Permission issues can be resolved by changing permissions on certain files. Although not the most ideal or user-friendly option, this is not necessarily bad.
I never suggested to restart apache. If you read my post. The OP is the one asking wither apache should be restarted.
You basically re-worded what I said.

As for PHP. I guess if you don't mind 777 and 666 permissions than have at it. It might be the fastest way to run php,(which has nothing to do with plesk) but it's hardly secure. Open base directory is solely for php. What happens if the user uploads a perl script? If you must run mod_php better to use mod_ruid2 along with it. :)

IF memory is really that much of a concern consider running apache in worker_mpm with fast-cgi. or even better php-fpm. php-fpm is really fast and secure. :) That all depends on how many virtual hosts you have and memory, but the OP never mentioned any of that.
Post Reply