WordPress eating CPU, extremelly slow
-
Hi,
Some months ago I started working in a couple of WP website projects that were already being developed, were I’m supposed to apply some customizations not achievable by plugins, etc.
The thing is that these sites are extremelly slow. Previously they were installed on an old VPS, and when several people were using the Admin (and probably some visits too, not a lot) loading times would be around 15 seconds, or even a “timeout” error in browser.
The traffic on the sites is around 10 visits per minute, with values around 300-600 daily visits.
I moved the sites to a dedicated Cloud storage managed by myself (2.2Ghz 6 cores, 3Gb RAM), and loading times went down to around 3-5 seconds in the worst cases.
But anyway, as time goes by, this has become unbearable. We don’t want our sites to go slow, they should load instantly, or at least, in 1 second max.
Currently we use the W3Total Cache, and with the page cache enabled (cleared daily), pages load instantly, but those pages not cached take several seconds.
The problem is that, when a FEW requests come at the same time, the CPU gets so saturated that a page that with a free CPU loads in 2 seconds, ends up taking 8 seconds.
I’ve been doing some debugging with PHP, following the WP load code, line by line, function by function, and noticed that just the loop loading the plugins take 4 seconds.
I even isolated the loading times by plugin. Some of them take 0.00020 seconds, some 0.020 (not fast, but “acceptable” I guess), but other ones take between 0.100 and 0.300, with a couple of the bigger ones taking 0.900 seconds. You sum up all this, and get the 4 seconds loading time. And it can go up to 8 or 11 seconds if you do more than one request.
I’ve been developing websites with PHP for 20 years, and I’ve never seen a situation like this. I refuse to believe that a PHP just loading some code takes several seconds. Only similar things I’ve seen are scripts that import/export data, looping thousands of records from a file, inserting data into several tables, etc…
How is it possible that some plugins make the PHP core take several seconds to process some code, loading the CPU at 100%, and making the next request even slower? What’s happening there? My problem are not rendering or downloading times. It’s the browser doing it’s “thinking” thing for several seconds before it gets any response from the server to start rendering the site.
One of the sites has some hundreds of products (<1000) with a LOT of variations.
I though this could be a reason for the long loading times (maybe a bloated DB), so I tried creating a CLEAN WP install, and then started adding the plugins used on the site, one by one. Of course the loading time went up slowly, to the point that a WP site, without any content, just a Home and a “Hello World” post, took 5 seconds to load. So variations had nothing, or little, to do (this is the site linked to the post).
Even if it could be, I don’t think is server-resource related, because we also host another site I developed with just PHP, and it works without any problems. This website even connects to a remote API to search for accommodations, gets a response, and instantly renders a website with lots of information retrieved from several database tables, without any added cache, optimizations, image lazy loading, CSS minimify, JS minimify, or any other of those recommendations around to “make WP load faster”.
These are the plugins installed, in case in triggers some alarm on someone:
– Genesis theme + lily
– Genesis Extender
– W3 Total Cache
– Sucuri Security – Auditing, Malware Scanner and Hardening
– WooCommerce
– Genesis Connect for WooCommerce
– Variation Swatches for WooCommerce
– Variation Swatches for WooCommerce – Pro
– Smart Variations Images & Swatches for WooCommerce (Premium)
– Premmerce Permalink Manager for WooCommerce
– WPC AJAX Add to Cart for WooCommerce
– WooCommerce Conditional Content
– Advanced AJAX Product Filters for WooCommerce
– Cantidad mínima y máxima para Woocommerce
– Custom Shipping Methods for WooCommerce
– FiboSearch – AJAX Search for WooCommerce
– WooCommerce Load More Products
– WooCommerce Servired/RedSys Spain Gateway
– Facebook for WooCommerce
– Kadence WooCommerce Email Designer
– YITH WooCommerce Product Add-ons & Extra Options
– Advanced Custom Fields
– Max Mega Menu
– Max Mega Menu – Pro Addon
– ZP Shortcodes
– Click to Chat
– CMB2
– Coming Soon Page, Maintenance Mode & Landing Pages by SeedProd
– Disable Responsive Images Complete
– Easy WP SMTP
– Font Awesome
– GA Google Analytics
– GDPR Cookie Consent
– Genesis 404
– Google Ads & Marketing by Kliken
– Gravity Forms
– Limit Login Attempts Reloaded
– Loco Translate
– Plugin Notes Plus
– PublishPress Capabilities
– Really Simple SSL
– Redirection
– Shoppable Images Lite
– SVG Support
– WPS Hide Login
– Yoast SEOApart from this, I’ve got a custom PHP functions file with around 4000 lines, custom JS with 2600 lines and custom CSS with around 6000 lines.
This site is HEAVILY modified, but I have also tested this removing these customizations, and didn’t see any noticeable speed improvements.
If you open the site linked in the post, and then open in a new tab the Hello World post 5, or even 10 times, you will notice how long it takes to load the page. And it’s just a title and a text…
It will also depend on how busy is the server, and that’s what I don’t understand.
(If you want to try the actual website, just remove the “dev2” subdomain from the URL)
This is the accommodation site I mentioned before (non-WP):
https://deskontaliaviajes.com/alquileres-vacacionales/listado.php?whereto=costa+brava&rid=12®ion=Costa+BravaIt loads fast even if I try to “stress” it loading several accommodations at same time, while the WP is struggling to load several tabs at the same time.
So basically, what can I do here?
I have tried:
– Different caches (W3TC current).
– Disabled admin-ajax.
– Disabled cron.
– Reduced PHP memory to minimum value without error (256mb).
– Removed unused action hooks.
– Removed unused plugins.
– Updated plugins.
– Configured PHP to run as dedicated Apache for each site
– Activated nginx cache.
– … Possibly something else I already forgot.I don’t know what else to try. If you think I could need some server tweaking, please let me know what info I can give you to check if everything is on the recommended values.
As a possible fix to improve speed, I’ve been thinking doing the following:
– In the loop loading the plugins (wp-settins), add PHP code to avoid the loading of plugins that do nothing to the content (admin plugins and similar).
– In this same loop, add a custom code, and depending on the page being loaded (home, a product detail, product list, contact…) load only certain plugins. Something like “if page is product detail, exclude plugins 3,6,1,38,13,11,15”.My final target is to create this website from the ground using just PHP and get rid of WP once and for all, but first they want me to try fix the speed issues 🙂
Any help or orientation would be appreciated.
Thanks in advance,
Regards.- This topic was modified 4 years, 4 months ago by . Reason: Moved to Fixing WordPress, this is not an Everything else WordPress topic
The page I need help with: [log in to see the link]
The topic ‘WordPress eating CPU, extremelly slow’ is closed to new replies.