Portal Home > Knowledgebase > Articles Database > VPS high cpu usage Wordpress


VPS high cpu usage Wordpress




Posted by jyciap11, 12-15-2015, 03:30 PM
Hello guys, I've wordpress in my VPS 2 core 3GB RAM, and i've always server load between 0.20 and 0.70, ram 14% and cpu usage 1-2%. When I publish new articles or edit new articles, my wordpress charge, charge and charge.. and often he didn't change or publish articles, server load was 10/11, ram 30% and CPU 100%. If I close the articles page all is ok. I check also that my Wordpress panel is really really slow. In my vps I check this: 87.0 domain/index.php 82.0 domain/index.php 76.0 domain/wp-admin/index.php

Posted by jyciap11, 12-15-2015, 04:08 PM
And in log I see this all days many times: PHP Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0

Posted by pressjitsu, 12-15-2015, 04:21 PM
If possible you should run a PHP profile on your save post/publish request. You'll be able to analyze the request and see where the time is spent. Xdebug and XHProf are good profilers. If you don't want to or can't do profiling, I suggest you deactivate all plugins and activate the default theme, see if publishing is still that slow. If it it's not, then start activating your plugins one by one (and theme), sooner or later you'll find the one causing the load. Hope that helps!

Posted by jyciap11, 12-15-2015, 04:26 PM
Hello Pressjitsu. I can't disable aall my plugin, I disabled all except seo yoast and itheme security because I need this. Hosting increase my php memory but it didn't change anything..

Posted by pressjitsu, 12-15-2015, 04:27 PM
Yeah, looks like you're working on a production site. In that case I strongly suggest you run a profile with XHProf, it's lightweight and usable in production environments, you'll be able to see all the function calls and their timing in the report.

Posted by jyciap11, 12-15-2015, 04:41 PM
Oh, I forgot this, the problem is ONLY the morning. At the afternoon/night, wordpress publish my articles in 9-10 seconds, but only the mornings it takes 6-7-8 minutes (and often don't publish). How can I check if there are any process or other like this that use some cpu at morning?

Posted by pressjitsu, 12-15-2015, 04:47 PM
You can get a list of running processes along with their CPU and memory usage with "ps aux" or "top" via SSH.

Posted by jyciap11, 12-15-2015, 04:51 PM
I've cpanel, and I see in process manager that when I publish articles i've 2-3 index.php that use 70-80-90& cpu. In the morning VPS stay in this situations for a long long time, in the afternoon after 10-15 seconds all be ok.

Posted by pressjitsu, 12-15-2015, 04:54 PM
If it's index.php then it's most likely WordPress, not a different process. Again, a PHP profile will reveal the details. Hire a PHP/sysadmin consultant if you think you can't handle profiling yourself. Setting up and working with XHProf is really not that complicated: http://php.net/xhprof

Posted by BACKUP SPIDER, 12-15-2015, 09:55 PM
Are you running Apache? With Wordpress Nginx makes a nice performance boost.

Posted by acm_whr, 12-16-2015, 01:54 AM
Hello, First, install w3 super cache and also optimize your MYSQL database of your particular domain. Then if you are using custom theme please change the theme to a default WP theme to see if the problem persists.

Posted by pressjitsu, 12-16-2015, 01:59 AM
@acm_whr It's W3 Total Cache or WP Super Cache, but not W3 Super Cache Also worth noting that a caching plugin will probably not help in this particular situation, since 1. Save draft/publish is a POST request which should never hit cache, and 2. The user is logged in to wp-admin at the time of posting, which should also not be cached. @jyciap11 You mentioned you can't disable all your plugins/theme, however, I should clarify that by disabling I meant temporarily disable to see what's causing the issue. You can pick a convenient time for this, when there are few visitors on your website. You can also warn them of a "maintenance window" upfront, even serve them a 503 during that time with your apache/nginx config.

Posted by jyciap11, 12-16-2015, 05:11 AM
PROBLEM FOUND! Is the Goggle Sitemap Generator plugin... but how can I disable it? I need it ..

Posted by pressjitsu, 12-16-2015, 05:41 AM
You can look for a more lightweight alternative in the plugins repo. Btw Yoast SEO can probably do sitemaps too, check out their settings pages.

Posted by jyciap11, 12-16-2015, 05:42 AM
But if I change sitemap Google will deindex my articles?

Posted by pressjitsu, 12-16-2015, 07:15 AM
Google will not deindex your articles even if you completely remove your sitemaps.

Posted by jyciap11, 12-16-2015, 06:17 PM
I've other question.. I've currently set my php memory to 128M, can I set to 256M or it is too high?

Posted by pressjitsu, 12-16-2015, 06:18 PM
Why would you like to set it to 256M?

Posted by jyciap11, 12-16-2015, 06:21 PM
Because I deactivated sitemap and other plugin but i've the same problem, ask my hosting that increase memory to 128M but didn't change anything, so I've 3GB ram in my vps and I think that can i use 256 or 512 for my php process right? In this case I think all my slow problem disappeared

Posted by pressjitsu, 12-16-2015, 06:40 PM
If you were hitting PHP's memory limit you'd see a bunch of fatal errors (allowed memory size exhausted). Throwing more memory at PHP hoping that it becomes faster is not how it works. You can be using 16mb of memory or less, and still taking up all the CPU time and hence causing high load. Use a plugin such as Debug Bar to find out your memory usage per request, and for crying out loud, just run a PHP profile already

Posted by jyciap11, 12-16-2015, 06:44 PM
I follow your advice, and I install query plugin, and after published articles I check this red query: SELECT DISTINCT meta_key FROM wp_postmeta WHERE meta_key NOT BETWEEN '_' AND '_z' HAVING meta_key NOT LIKE '\\_%' ORDER BY meta_key LIMIT 30

Posted by superuser_root, 12-17-2015, 01:23 AM
Hi, I would suggest to install nginx in your server as this would improve the server performance. If that didn't help much, try the php handler as dso with mod_ruid and apc cache enabled which will surely improve the performance.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Web hosting stories (Views: 649)
Beware of Mesopia.com (Views: 637)

Language: