• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Wordpress and CPU Usage

Robin McDermott

Basic Pleskian
I am having some speed issues with Wordpress. We started noticing them when our colleague in Australia was trying to work on wordpress that is on our Dedicated Peer 1 server in Miami, FL. I started getting messages from the server about APACHE CPU usage going from green to yellow to red. While we were getting these alarms, running webpages didn't seem slow.

Investigation led us to watching CPU usage when accessing wordpress pages or doing anything in the WP admin panel. Consistently CPU usage goes up in either case to the high 20's to low 30%. Sometimes the user is the website and other times it is apache. Most often the spike is associated with the user and the command is php-cgi.

I recently migrated to a new server so the WP sites were imported to the new server. However, I now have set up a new domain and installed WP through Plesk and have only installed a theme and still notice the high CPU usage for that domains user.

Perhaps I need to take a closer look at the PHP settings? Any other ideas?

Thanks in advance!
Robin
 
I was using Apache as the php handler and I have switched to Fast CGI and it seems faster. Do you have any suggested best practices in terms of a PHP handler when using Wordpress. I have read a variety of opinions on this, but am specifically interested in guidelines from Plesk.

I didn't find any errors in the logs.

I did learn a little more about the CPU warnings. Our server is 6 cores - 12 threads so as I understand it, the warning is based on usage of any one core? I have changed the warning settings so that I get a yellow alert when it hits 30% (up from 20%) and red when it hits 50% (up from 25%). Does this make sense?

I also did a clean installation of the wordpress site and installed only the plugins needed at this time.

Hopefully this will help someone with a similar problem down the road.

Robin
 
@Robin,

It is common practice that WordPress instances are using a lot of resources, during wpcron processes.

For that reason alone, I should recommend that you have a look at the cron processes run by the WordPress sites.

In addition, the latest versions of WP (> 4.4) are working best with PHP 7.0 and second best with PHP 5.6.17.

Running an older WP version on PHP 7.0 OR running a latest WP version on PHP 5.5 (and lower) will be associated with some performance penalties.

Furthermore, I am not sure whether you have Nginx installed, but that could and will improve performance on the whole.

Finally, the performance of the WordPress sites does not have to be related to WordPress, but often is the result of Apache settings.

For instance, having a very short Apache restart interval can cause performance problems, if you have a lot of domains hosted on the server.

As another example, the use of FastCGI improves performance (as you have noticed), while php-fpm will increase performance even more.

In short, choose your Apache + WP stack carefully.

I would recommend that you use a WP version higher than 4.4, run PHP 7.0, enable Nginx and enable php-fpm (on the Apache side, not on Nginx).

Hope the above helps...

Regards....
 
Hi Trialotto, Thank you so much for this valuable insight. I am using PHP 5.3.3 so that is something I will look into.

I see where I can make other versions of PHP available to my server:

upload_2016-2-15_14-8-16.png

I only see PHP-FPM available under NGINX, which as you can see is also not available. I will make NGINX available, but where would I find the php-fpm "on the Apache side."

I am using WP 4.4.2 so it sounds like I am doing something right ;-)

Robn
 

Attachments

  • upload_2016-2-15_14-1-25.png
    upload_2016-2-15_14-1-25.png
    17.4 KB · Views: 5
@Robin McDermott,

I was reading your response, until I ended up at "I am using WP 4.4.2 so it sounds like I am doing something right ;-)" and started a big laugh (aloud). Nice, thanks!

Yes, indeed, the right WP version, but the wrong PHP version.

All you have to do is the following:

1) install PHP 5.6 (and, for the sake of convenience, install PHP 7.0 at the same time),

2) go to "Domains" in the Plesk Panel, select the site containing the WP instance (i.e. click on the name), click on "PHP Settings" and

- check checkbox "PHP Support (PHP version" and select version 5.6.17,
- with "run PHP as" set to "FPM application served by Apache"

and click on "OK" (or press enter).

Just wait a couple of seconds and your performance issues should be history.

If you want to use PHP 7.0.2, you can follow the same procedure.

Please note that using PHP 5.4 or lower is not recommended, implying that you should follow the above steps for each domain with PHP 5.4 or lower.

Hope the above helps.

Regards....
 
Hi Trialotto,

I LIKE the part about making performance issues history! :)

You make it sound so easy, but I always have to plan for the worst. Making those other versions of PHP available on the server shouldn't impact any sites until I specifically assign the newer version of PHP to that site...correct. On my site with the biggest problems, I am only testing Wordpress and I can easily test that version of PHP with my other php programs on that site. I assume reverting back is as simple as changing back?

What about the NGINX? Or is that not necessary.

I really can't thank you enough...especially if my whole server doesn't come crashing down when I make these changes ;-)

Robin
 
@Robin McDermott

Ehm, to be honest, mechanical things and software have the nasty habit to "crash" and you often cannot kick it to make it work. That was the case in the good old days.

You stated

On my site with the biggest problems, I am only testing Wordpress and I can easily test that version of PHP with my other php programs on that site. I assume reverting back is as simple as changing back?

and, in essence, reverting back is a simple as choosing another PHP version, i.e. the older PHP version.

There is this thing to note though: specific php modules for older versions are non-existent or changed in newer versions, so you should always take care that compability exists.

In your statement, I read the message "between the lines" that you have a WordPress instance AND some other php code. Is that correct?

If so, you should be aware of the fact that some of the older PHP code involves functions that have been deprecated in time, but this problem does not really often occur AND the benefit of using the new code and/or improvements of old code is huge: in a sense, you sooner or later have to update code to be compatible with later or latest versions of PHP code.

In general, a PHP version change will not break a server (only php scripts occassionally) and will certainly not break WordPress (WP will can handle PHP 5.6 and higher even better).

Furthermore, you asked the question(s)

What about the NGINX? Or is that not necessary.

and the short answer is: no, not necessary, only strongly recommended.

Nginx is a proxy server for Apache, making it possible to boost performance: for example, you can use Nginx to serve static files, while having Apache only handling php requests.

Furthermore, the Nginx provided with Plesk is reliable and stable, with a lot of advanced configuration possibilities, allowing you to use Nginx in all flexibility imaginable.

And it only requires installing Nginx.

The disadvantage is that installing Nginx also implies that you will install Nginx for all domains (that is not really a disadvantage, but it is good to mention).

However, you will barely notice the presence of Nginx, except for a boost in performance, certainly when having Nginx set to serving static files.

In short, just give Nginx a chance and try it.

Regards.......
 
Hello Trialotto,

I have made some changes to our server - need to do that type of work on the weekend when usage is low.

  • I added PHP 5.6 and 7 as options in plesk.
  • Started the Reverse Proxy Server (nginx) in services.
  • Upgraded two websites to PHP 5.6 Fast CGI

PHP 5.6 FPM via apache is not an option. (FPM via NGINX is, but that is not the option you recommended.)

When I look at services, I see PHP-FPM for v 5.6.18 and 7.0.3 but they are disabled and when I mouseover the circle icon to the left, it says services not configured.

Would you have advice on how to get these services configured?

Thank you again for your advice and guidance.

Robin
 
@Robin McDermott

I suppose that the installation of the new PHP versions went without a problem, but I am not so sure, given the contents of your post.

You asked

When I look at services, I see PHP-FPM for v 5.6.18 and 7.0.3 but they are disabled and when I mouseover the circle icon to the left, it says services not configured.

Would you have advice on how to get these services configured?

and I had to think about that for a little bit, shame on me.

Normally, it is just activating the FPM on a specific domain, at least that should be it (if the PHP installation was correct).

That is, it should be as easy as: just go to "Domains > [domain] > PHP Settings" and select "PHP version x.x.x" and "FPM application served by Apache".

Again, note that I am still thinking: why is "PHP 5.6 FPM via apache" not an option?

You stated that, but it should be the case that you should be able to enable "FPM application served by Apache", after having installed the new PHP versions.

Was there anything that I am missing, or went something wrong with the PHP installation?

Please let me know....

Regards
 
Hi Trialotto,

The FPM Apache option is not available:

upload_2016-2-20_23-41-45.png

No doubt I have not configured something correctly, but I am not sure of what that is??

Robin
 
@Robin McDermott

That is strange.

Can you verify the presence of FPM by going to "Tools & Settings > PHP Settings": there should be a "5.6.18 FPM Application" with a green box for it. If it is grey, click on it.

Let me know what you found.

Regards
 
@Robin McDermott

To be honest, I am not sure what happens in your situation. I tried to reproduce your situation (and issue) many times, but did fail miserably (every time).

The php-fpm handlers are working for all installed PHP versions.

Does it make a difference if you select another PHP version, click on OK (to apply the settings) and then retry the PHP 5.6.18 version?

Also, can you give the output from the command: service plesk-php56-fpm status

What you can try is to run the following commands (in chronological order)

- service plesk-php56-fpm stop
- service plesk-php56-fpm start

and this would "tickle" the php-fpm handler a little bit.

Let me know, I am still curious what happend in your case.

Regards....
 
To run php through apache FPM you need apache 2.4. You can find out apache's version by typing the following command:
Debian/Ubuntu: apache2 -v
RHEL/CentOS/Cloudlinux: httpd -v
 
between the FASTCGI and FPM which is better?
FPM by far, especially if you use it with nginx. I especially like the php7+nginx stack lately, as it blows apache by far! Also have a look at the number of requests your site creates, as it has a small impact as well on the server.
 
Back
Top